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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 : m_source(PasteboardSource) | 96 : m_source(PasteboardSource) |
97 , m_kind(kind) | 97 , m_kind(kind) |
98 , m_type(type) | 98 , m_type(type) |
99 , m_sequenceNumber(sequenceNumber) | 99 , m_sequenceNumber(sequenceNumber) |
100 { | 100 { |
101 } | 101 } |
102 | 102 |
103 PassRefPtr<Blob> DataObjectItem::getAsFile() const | 103 PassRefPtr<Blob> DataObjectItem::getAsFile() const |
104 { | 104 { |
105 if (kind() != FileKind) | 105 if (kind() != FileKind) |
106 return 0; | 106 return nullptr; |
107 | 107 |
108 if (m_source == InternalSource) { | 108 if (m_source == InternalSource) { |
109 if (m_file) | 109 if (m_file) |
110 return m_file; | 110 return m_file; |
111 ASSERT(m_sharedBuffer); | 111 ASSERT(m_sharedBuffer); |
112 // FIXME: This code is currently impossible--we never populate m_sharedB
uffer when dragging | 112 // FIXME: This code is currently impossible--we never populate m_sharedB
uffer when dragging |
113 // in. At some point though, we may need to support correctly converting
a shared buffer | 113 // in. At some point though, we may need to support correctly converting
a shared buffer |
114 // into a file. | 114 // into a file. |
115 return 0; | 115 return nullptr; |
116 } | 116 } |
117 | 117 |
118 ASSERT(m_source == PasteboardSource); | 118 ASSERT(m_source == PasteboardSource); |
119 if (type() == mimeTypeImagePng) { | 119 if (type() == mimeTypeImagePng) { |
120 // FIXME: This is pretty inefficient. We copy the data from the browser | 120 // FIXME: This is pretty inefficient. We copy the data from the browser |
121 // to the renderer. We then place it in a blob in WebKit, which | 121 // to the renderer. We then place it in a blob in WebKit, which |
122 // registers it and copies it *back* to the browser. When a consumer | 122 // registers it and copies it *back* to the browser. When a consumer |
123 // wants to read the data, we then copy the data back into the renderer. | 123 // wants to read the data, we then copy the data back into the renderer. |
124 // https://bugs.webkit.org/show_bug.cgi?id=58107 has been filed to track | 124 // https://bugs.webkit.org/show_bug.cgi?id=58107 has been filed to track |
125 // improvements to this code (in particular, add a registerClipboardBlob | 125 // improvements to this code (in particular, add a registerClipboardBlob |
126 // method to the blob registry; that way the data is only copied over | 126 // method to the blob registry; that way the data is only copied over |
127 // into the renderer when it's actually read, not when the blob is | 127 // into the renderer when it's actually read, not when the blob is |
128 // initially constructed). | 128 // initially constructed). |
129 RefPtr<SharedBuffer> data = static_cast<PassRefPtr<SharedBuffer> >(blink
::Platform::current()->clipboard()->readImage(blink::WebClipboard::BufferStandar
d)); | 129 RefPtr<SharedBuffer> data = static_cast<PassRefPtr<SharedBuffer> >(blink
::Platform::current()->clipboard()->readImage(blink::WebClipboard::BufferStandar
d)); |
130 RefPtr<RawData> rawData = RawData::create(); | 130 RefPtr<RawData> rawData = RawData::create(); |
131 rawData->mutableData()->append(data->data(), data->size()); | 131 rawData->mutableData()->append(data->data(), data->size()); |
132 OwnPtr<BlobData> blobData = BlobData::create(); | 132 OwnPtr<BlobData> blobData = BlobData::create(); |
133 blobData->appendData(rawData, 0, -1); | 133 blobData->appendData(rawData, 0, -1); |
134 blobData->setContentType(mimeTypeImagePng); | 134 blobData->setContentType(mimeTypeImagePng); |
135 return Blob::create(BlobDataHandle::create(blobData.release(), data->siz
e())); | 135 return Blob::create(BlobDataHandle::create(blobData.release(), data->siz
e())); |
136 } | 136 } |
137 | 137 |
138 return 0; | 138 return nullptr; |
139 } | 139 } |
140 | 140 |
141 String DataObjectItem::getAsString() const | 141 String DataObjectItem::getAsString() const |
142 { | 142 { |
143 ASSERT(m_kind == StringKind); | 143 ASSERT(m_kind == StringKind); |
144 | 144 |
145 if (m_source == InternalSource) | 145 if (m_source == InternalSource) |
146 return m_data; | 146 return m_data; |
147 | 147 |
148 ASSERT(m_source == PasteboardSource); | 148 ASSERT(m_source == PasteboardSource); |
(...skipping 16 matching lines...) Expand all Loading... |
165 | 165 |
166 bool DataObjectItem::isFilename() const | 166 bool DataObjectItem::isFilename() const |
167 { | 167 { |
168 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=81261: When we properly su
pport File dragout, | 168 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=81261: When we properly su
pport File dragout, |
169 // we'll need to make sure this works as expected for DragDataChromium. | 169 // we'll need to make sure this works as expected for DragDataChromium. |
170 return m_kind == FileKind && m_file; | 170 return m_kind == FileKind && m_file; |
171 } | 171 } |
172 | 172 |
173 } // namespace WebCore | 173 } // namespace WebCore |
174 | 174 |
OLD | NEW |