|
Lines 23-31
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec1
|
| 23 |
#include "DataObjectGtk.h" |
23 |
#include "DataObjectGtk.h" |
| 24 |
#include "DragData.h" |
24 |
#include "DragData.h" |
| 25 |
#include "Image.h" |
25 |
#include "Image.h" |
|
|
26 |
#include "PasteboardStrategy.h" |
| 27 |
#include "PlatformStrategies.h" |
| 26 |
#include "URL.h" |
28 |
#include "URL.h" |
| 27 |
#include "PasteboardHelper.h" |
29 |
#include <wtf/NeverDestroyed.h> |
| 28 |
#include <gtk/gtk.h> |
|
|
| 29 |
|
30 |
|
| 30 |
namespace WebCore { |
31 |
namespace WebCore { |
| 31 |
|
32 |
|
|
Lines 40-51
enum ClipboardDataType {
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec2
|
| 40 |
|
41 |
|
| 41 |
std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste() |
42 |
std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste() |
| 42 |
{ |
43 |
{ |
| 43 |
return std::make_unique<Pasteboard>(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); |
44 |
return std::make_unique<Pasteboard>("CLIPBOARD"); |
| 44 |
} |
45 |
} |
| 45 |
|
46 |
|
| 46 |
std::unique_ptr<Pasteboard> Pasteboard::createForGlobalSelection() |
47 |
std::unique_ptr<Pasteboard> Pasteboard::createForGlobalSelection() |
| 47 |
{ |
48 |
{ |
| 48 |
return std::make_unique<Pasteboard>(gtk_clipboard_get(GDK_SELECTION_PRIMARY)); |
49 |
return std::make_unique<Pasteboard>("PRIMARY"); |
| 49 |
} |
50 |
} |
| 50 |
|
51 |
|
| 51 |
std::unique_ptr<Pasteboard> Pasteboard::createPrivate() |
52 |
std::unique_ptr<Pasteboard> Pasteboard::createPrivate() |
|
Lines 76-92
PasteboardImage::~PasteboardImage()
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec3
|
| 76 |
|
77 |
|
| 77 |
Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject) |
78 |
Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject) |
| 78 |
: m_dataObject(WTFMove(dataObject)) |
79 |
: m_dataObject(WTFMove(dataObject)) |
| 79 |
, m_gtkClipboard(nullptr) |
|
|
| 80 |
{ |
80 |
{ |
| 81 |
ASSERT(m_dataObject); |
81 |
ASSERT(m_dataObject); |
| 82 |
} |
82 |
} |
| 83 |
|
83 |
|
| 84 |
Pasteboard::Pasteboard(GtkClipboard* gtkClipboard) |
84 |
Pasteboard::Pasteboard(const String& name) |
| 85 |
: m_dataObject(DataObjectGtk::create()) |
85 |
: m_dataObject(DataObjectGtk::create()) |
| 86 |
, m_gtkClipboard(gtkClipboard) |
86 |
, m_name(name) |
| 87 |
{ |
87 |
{ |
| 88 |
ASSERT(m_dataObject); |
|
|
| 89 |
PasteboardHelper::singleton().registerClipboard(gtkClipboard); |
| 90 |
} |
88 |
} |
| 91 |
|
89 |
|
| 92 |
Pasteboard::~Pasteboard() |
90 |
Pasteboard::~Pasteboard() |
|
Lines 121-126
static ClipboardDataType dataObjectTypeFromHTMLClipboardType(const String& rawTy
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec4
|
| 121 |
return ClipboardDataTypeUnknown; |
119 |
return ClipboardDataTypeUnknown; |
| 122 |
} |
120 |
} |
| 123 |
|
121 |
|
|
|
122 |
void Pasteboard::writeToClipboard(ShouldIncludeSmartPaste shouldIncludeSmartPaste) |
| 123 |
{ |
| 124 |
if (m_name.isNull()) |
| 125 |
return; |
| 126 |
m_dataObject->setCanSmartReplace(shouldIncludeSmartPaste == ShouldIncludeSmartPaste::Yes); |
| 127 |
platformStrategies()->pasteboardStrategy()->writeToClipboard(m_name, m_dataObject); |
| 128 |
} |
| 129 |
|
| 130 |
void Pasteboard::readFromClipboard() |
| 131 |
{ |
| 132 |
if (m_name.isNull()) |
| 133 |
return; |
| 134 |
m_dataObject = platformStrategies()->pasteboardStrategy()->readFromClipboard(m_name); |
| 135 |
} |
| 136 |
|
| 124 |
void Pasteboard::writeString(const String& type, const String& data) |
137 |
void Pasteboard::writeString(const String& type, const String& data) |
| 125 |
{ |
138 |
{ |
| 126 |
switch (dataObjectTypeFromHTMLClipboardType(type)) { |
139 |
switch (dataObjectTypeFromHTMLClipboardType(type)) { |
|
Lines 147-154
void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartRepl
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec5
|
| 147 |
m_dataObject->clearAll(); |
160 |
m_dataObject->clearAll(); |
| 148 |
m_dataObject->setText(text); |
161 |
m_dataObject->setText(text); |
| 149 |
|
162 |
|
| 150 |
if (m_gtkClipboard) |
163 |
writeToClipboard(smartReplaceOption == CanSmartReplace ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No); |
| 151 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject, (smartReplaceOption == CanSmartReplace) ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste); |
|
|
| 152 |
} |
164 |
} |
| 153 |
|
165 |
|
| 154 |
void Pasteboard::write(const PasteboardURL& pasteboardURL) |
166 |
void Pasteboard::write(const PasteboardURL& pasteboardURL) |
|
Lines 158-165
void Pasteboard::write(const PasteboardURL& pasteboardURL)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec6
|
| 158 |
m_dataObject->clearAll(); |
170 |
m_dataObject->clearAll(); |
| 159 |
m_dataObject->setURL(pasteboardURL.url, pasteboardURL.title); |
171 |
m_dataObject->setURL(pasteboardURL.url, pasteboardURL.title); |
| 160 |
|
172 |
|
| 161 |
if (m_gtkClipboard) |
173 |
writeToClipboard(); |
| 162 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 163 |
} |
174 |
} |
| 164 |
|
175 |
|
| 165 |
void Pasteboard::write(const PasteboardImage& pasteboardImage) |
176 |
void Pasteboard::write(const PasteboardImage& pasteboardImage) |
|
Lines 174-181
void Pasteboard::write(const PasteboardImage& pasteboardImage)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec7
|
| 174 |
if (pixbuf) |
185 |
if (pixbuf) |
| 175 |
m_dataObject->setImage(pixbuf.get()); |
186 |
m_dataObject->setImage(pixbuf.get()); |
| 176 |
|
187 |
|
| 177 |
if (m_gtkClipboard) |
188 |
writeToClipboard(); |
| 178 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 179 |
} |
189 |
} |
| 180 |
|
190 |
|
| 181 |
void Pasteboard::write(const PasteboardWebContent& pasteboardContent) |
191 |
void Pasteboard::write(const PasteboardWebContent& pasteboardContent) |
|
Lines 184-191
void Pasteboard::write(const PasteboardWebContent& pasteboardContent)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec8
|
| 184 |
m_dataObject->setText(pasteboardContent.text); |
194 |
m_dataObject->setText(pasteboardContent.text); |
| 185 |
m_dataObject->setMarkup(pasteboardContent.markup); |
195 |
m_dataObject->setMarkup(pasteboardContent.markup); |
| 186 |
|
196 |
|
| 187 |
if (m_gtkClipboard) |
197 |
writeToClipboard(pasteboardContent.canSmartCopyOrDelete ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No); |
| 188 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject, pasteboardContent.canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste, pasteboardContent.callback.get()); |
|
|
| 189 |
} |
198 |
} |
| 190 |
|
199 |
|
| 191 |
void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard) |
200 |
void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard) |
|
Lines 208-215
void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec9
|
| 208 |
m_dataObject->setUnknownTypeData(it.key, it.value); |
217 |
m_dataObject->setUnknownTypeData(it.key, it.value); |
| 209 |
} |
218 |
} |
| 210 |
|
219 |
|
| 211 |
if (m_gtkClipboard) |
220 |
writeToClipboard(); |
| 212 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 213 |
} |
221 |
} |
| 214 |
|
222 |
|
| 215 |
void Pasteboard::clear() |
223 |
void Pasteboard::clear() |
|
Lines 219-227
void Pasteboard::clear()
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec10
|
| 219 |
// attribute's list might still not be empty after calling clearData() (it would |
227 |
// attribute's list might still not be empty after calling clearData() (it would |
| 220 |
// still contain the "Files" string if any files were included in the drag)." |
228 |
// still contain the "Files" string if any files were included in the drag)." |
| 221 |
m_dataObject->clearAllExceptFilenames(); |
229 |
m_dataObject->clearAllExceptFilenames(); |
| 222 |
|
230 |
writeToClipboard(); |
| 223 |
if (m_gtkClipboard) |
|
|
| 224 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); |
| 225 |
} |
231 |
} |
| 226 |
|
232 |
|
| 227 |
void Pasteboard::clear(const String& type) |
233 |
void Pasteboard::clear(const String& type) |
|
Lines 245-257
void Pasteboard::clear(const String& type)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec11
|
| 245 |
break; |
251 |
break; |
| 246 |
} |
252 |
} |
| 247 |
|
253 |
|
| 248 |
if (m_gtkClipboard) |
254 |
writeToClipboard(); |
| 249 |
PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 250 |
} |
255 |
} |
| 251 |
|
256 |
|
| 252 |
bool Pasteboard::canSmartReplace() |
257 |
bool Pasteboard::canSmartReplace() |
| 253 |
{ |
258 |
{ |
| 254 |
return m_gtkClipboard && PasteboardHelper::singleton().clipboardContentSupportsSmartReplace(m_gtkClipboard); |
259 |
readFromClipboard(); |
|
|
260 |
return m_dataObject->canSmartReplace(); |
| 255 |
} |
261 |
} |
| 256 |
|
262 |
|
| 257 |
#if ENABLE(DRAG_SUPPORT) |
263 |
#if ENABLE(DRAG_SUPPORT) |
|
Lines 262-284
void Pasteboard::setDragImage(DragImageRef, const IntPoint&)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec12
|
| 262 |
|
268 |
|
| 263 |
void Pasteboard::read(PasteboardPlainText& text) |
269 |
void Pasteboard::read(PasteboardPlainText& text) |
| 264 |
{ |
270 |
{ |
| 265 |
if (m_gtkClipboard) |
271 |
readFromClipboard(); |
| 266 |
PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 267 |
text.text = m_dataObject->text(); |
272 |
text.text = m_dataObject->text(); |
| 268 |
} |
273 |
} |
| 269 |
|
274 |
|
| 270 |
bool Pasteboard::hasData() |
275 |
bool Pasteboard::hasData() |
| 271 |
{ |
276 |
{ |
| 272 |
if (m_gtkClipboard) |
277 |
readFromClipboard(); |
| 273 |
PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 274 |
|
| 275 |
return m_dataObject->hasText() || m_dataObject->hasMarkup() || m_dataObject->hasURIList() || m_dataObject->hasImage() || m_dataObject->hasUnknownTypeData(); |
278 |
return m_dataObject->hasText() || m_dataObject->hasMarkup() || m_dataObject->hasURIList() || m_dataObject->hasImage() || m_dataObject->hasUnknownTypeData(); |
| 276 |
} |
279 |
} |
| 277 |
|
280 |
|
| 278 |
Vector<String> Pasteboard::types() |
281 |
Vector<String> Pasteboard::types() |
| 279 |
{ |
282 |
{ |
| 280 |
if (m_gtkClipboard) |
283 |
readFromClipboard(); |
| 281 |
PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 282 |
|
284 |
|
| 283 |
Vector<String> types; |
285 |
Vector<String> types; |
| 284 |
if (m_dataObject->hasText()) { |
286 |
if (m_dataObject->hasText()) { |
|
Lines 306-313
Vector<String> Pasteboard::types()
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec13
|
| 306 |
|
308 |
|
| 307 |
String Pasteboard::readString(const String& type) |
309 |
String Pasteboard::readString(const String& type) |
| 308 |
{ |
310 |
{ |
| 309 |
if (m_gtkClipboard) |
311 |
readFromClipboard(); |
| 310 |
PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 311 |
|
312 |
|
| 312 |
switch (dataObjectTypeFromHTMLClipboardType(type)) { |
313 |
switch (dataObjectTypeFromHTMLClipboardType(type)) { |
| 313 |
case ClipboardDataTypeURIList: |
314 |
case ClipboardDataTypeURIList: |
|
Lines 329-337
String Pasteboard::readString(const String& type)
a/Source/WebCore/platform/gtk/PasteboardGtk.cpp_sec14
|
| 329 |
|
330 |
|
| 330 |
Vector<String> Pasteboard::readFilenames() |
331 |
Vector<String> Pasteboard::readFilenames() |
| 331 |
{ |
332 |
{ |
| 332 |
if (m_gtkClipboard) |
333 |
readFromClipboard(); |
| 333 |
PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); |
|
|
| 334 |
|
| 335 |
return m_dataObject->filenames(); |
334 |
return m_dataObject->filenames(); |
| 336 |
} |
335 |
} |
| 337 |
|
336 |
|