| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (type() == mimeTypeImagePng) { | 136 if (type() == mimeTypeImagePng) { |
| 137 // FIXME: This is pretty inefficient. We copy the data from the browser | 137 // FIXME: This is pretty inefficient. We copy the data from the browser |
| 138 // to the renderer. We then place it in a blob in WebKit, which | 138 // to the renderer. We then place it in a blob in WebKit, which |
| 139 // registers it and copies it *back* to the browser. When a consumer | 139 // registers it and copies it *back* to the browser. When a consumer |
| 140 // wants to read the data, we then copy the data back into the renderer. | 140 // wants to read the data, we then copy the data back into the renderer. |
| 141 // https://bugs.webkit.org/show_bug.cgi?id=58107 has been filed to track | 141 // https://bugs.webkit.org/show_bug.cgi?id=58107 has been filed to track |
| 142 // improvements to this code (in particular, add a registerClipboardBlob | 142 // improvements to this code (in particular, add a registerClipboardBlob |
| 143 // method to the blob registry; that way the data is only copied over | 143 // method to the blob registry; that way the data is only copied over |
| 144 // into the renderer when it's actually read, not when the blob is | 144 // into the renderer when it's actually read, not when the blob is |
| 145 // initially constructed). | 145 // initially constructed). |
| 146 // TODO: Could use a BlobRegistry interface to create a blobDataHandle d
irectly from the clipboard data w/o having to read it? |
| 146 RefPtr<SharedBuffer> data = static_cast<PassRefPtr<SharedBuffer> >(WebKi
t::Platform::current()->clipboard()->readImage(WebKit::WebClipboard::BufferStand
ard)); | 147 RefPtr<SharedBuffer> data = static_cast<PassRefPtr<SharedBuffer> >(WebKi
t::Platform::current()->clipboard()->readImage(WebKit::WebClipboard::BufferStand
ard)); |
| 147 RefPtr<RawData> rawData = RawData::create(); | 148 RefPtr<RawData> rawData = RawData::create(); |
| 148 rawData->mutableData()->append(data->data(), data->size()); | 149 rawData->mutableData()->append(data->data(), data->size()); |
| 149 OwnPtr<BlobData> blobData = BlobData::create(); | 150 OwnPtr<BlobData> blobData = BlobData::create(); |
| 150 blobData->appendData(rawData, 0, -1); | 151 blobData->appendData(rawData, 0, -1); |
| 151 blobData->setContentType(mimeTypeImagePng); | 152 blobData->setContentType(mimeTypeImagePng); |
| 152 return Blob::create(blobData.release(), data->size()); | 153 return Blob::create(BlobDataHandle::create(blobData.release(), data->siz
e())); |
| 153 } | 154 } |
| 154 | 155 |
| 155 return 0; | 156 return 0; |
| 156 } | 157 } |
| 157 | 158 |
| 158 String ChromiumDataObjectItem::internalGetAsString() const | 159 String ChromiumDataObjectItem::internalGetAsString() const |
| 159 { | 160 { |
| 160 ASSERT(m_kind == DataTransferItem::kindString); | 161 ASSERT(m_kind == DataTransferItem::kindString); |
| 161 | 162 |
| 162 if (m_source == InternalSource) | 163 if (m_source == InternalSource) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 181 bool ChromiumDataObjectItem::isFilename() const | 182 bool ChromiumDataObjectItem::isFilename() const |
| 182 { | 183 { |
| 183 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=81261: When we properly su
pport File dragout, | 184 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=81261: When we properly su
pport File dragout, |
| 184 // we'll need to make sure this works as expected for DragDataChromium. | 185 // we'll need to make sure this works as expected for DragDataChromium. |
| 185 return m_kind == DataTransferItem::kindFile && m_file; | 186 return m_kind == DataTransferItem::kindFile && m_file; |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace WebCore | 189 } // namespace WebCore |
| 189 | 190 |
| 190 #endif // ENABLE(DATA_TRANSFER_ITEMS) | 191 #endif // ENABLE(DATA_TRANSFER_ITEMS) |
| OLD | NEW |