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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromString(const St
ring& type, const String& data) | 42 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromString(const St
ring& type, const String& data) |
43 { | 43 { |
44 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, type)); | 44 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, type)); |
45 item->m_data = data; | 45 item->m_data = data; |
46 return item.release(); | 46 return item.release(); |
47 } | 47 } |
48 | 48 |
49 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromFile(PassRefPtr
<File> file) | 49 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromFile(PassRefPtr
WillBeRawPtr<File> file) |
50 { | 50 { |
51 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(FileKind, file->type())); | 51 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(FileKind, file->type())); |
52 item->m_file = file; | 52 item->m_file = file; |
53 return item.release(); | 53 return item.release(); |
54 } | 54 } |
55 | 55 |
56 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromURL(const Strin
g& url, const String& title) | 56 PassRefPtrWillBeRawPtr<DataObjectItem> DataObjectItem::createFromURL(const Strin
g& url, const String& title) |
57 { | 57 { |
58 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, mimeTypeTextURIList)); | 58 RefPtrWillBeRawPtr<DataObjectItem> item = adoptRefWillBeNoop(new DataObjectI
tem(StringKind, mimeTypeTextURIList)); |
59 item->m_data = url; | 59 item->m_data = url; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 DataObjectItem::DataObjectItem(Kind kind, const String& type, uint64_t sequenceN
umber) | 95 DataObjectItem::DataObjectItem(Kind kind, const String& type, uint64_t sequenceN
umber) |
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 PassRefPtrWillBeRawPtr<Blob> DataObjectItem::getAsFile() const |
104 { | 104 { |
105 if (kind() != FileKind) | 105 if (kind() != FileKind) |
106 return nullptr; | 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.get(); |
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 nullptr; | 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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return blink::Platform::current()->clipboard()->sequenceNumber(buffer) == m_
sequenceNumber ? data : String(); | 163 return blink::Platform::current()->clipboard()->sequenceNumber(buffer) == m_
sequenceNumber ? data : String(); |
164 } | 164 } |
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 void DataObjectItem::trace(Visitor* visitor) |
| 174 { |
| 175 visitor->trace(m_file); |
| 176 } |
| 177 |
173 } // namespace WebCore | 178 } // namespace WebCore |
174 | 179 |
OLD | NEW |