Changeset 205959 in webkit
- Timestamp:
- Sep 15, 2016 1:11:31 AM (8 years ago)
- Location:
- releases/WebKitGTK/webkit-2.14/Source
- Files:
-
- 4 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog
r205958 r205959 1 2016-09-14 Carlos Garnacho <carlosg@gnome.org> 2 3 [GTK][Wayland] Implement clipboard support 4 https://bugs.webkit.org/show_bug.cgi?id=146574 5 6 Reviewed by Carlos Garcia Campos. 7 8 Implement PlatformPasteboard in the GTK+ platform, and move Pasteboard 9 to using PasteboardStrategy so clipboard management is left to the 10 UIProcess. 11 12 DataObjectGtk is still used in the Pasteboard GTK implementation, it's 13 now just never backed by a GtkClipboard, this object is instead 14 serialized through PasteboardStrategy, so the UIProcess side can mirror 15 the content in a GtkClipboard-backed DataObjectGtk, which is then 16 exposed to the windowing through PlatformPasteboard/PasteboardHelper. 17 18 When requesting clipboard content, it works similarly, the UIProcess 19 side first updates its DataObjectGtk, which is then mirrored by the 20 WebProcess through the PasteboardStrategy requests. 21 22 * PlatformGTK.cmake: Added PlatformPasteboardGtk.cpp 23 * editing/gtk/EditorGtk.cpp: 24 (WebCore::Editor::writeSelectionToPasteboard): Eliminate usage of 25 PasteboardWebContent callback argument. This is done differently as 26 we have to signal back the WebProcess. 27 * platform/Pasteboard.h: Cleaned up of direct GTK+ dependency. 28 * platform/PasteboardStrategy.h: Added plumbing towards the pasteboard 29 proxy. 30 * platform/PlatformPasteboard.h: 31 * platform/gtk/DataObjectGtk.cpp: 32 (WebCore::DataObjectGtk::clearAllExceptFilenames): Clear the "smart 33 paste" flag if set, now that this is DataObjectGtk data. 34 * platform/gtk/DataObjectGtk.h: 35 (WebCore::DataObjectGtk::canSmartReplace): 36 (WebCore::DataObjectGtk::setCanSmartReplace): Added functions, in order 37 to flag whether a DataObjectGtk has the "smart paste" feature enabled 38 or not. 39 * platform/gtk/PasteboardGtk.cpp: 40 (WebCore::Pasteboard::createForCopyAndPaste): 41 (WebCore::Pasteboard::createForGlobalSelection): 42 (WebCore::Pasteboard::Pasteboard): 43 (WebCore::Pasteboard::writeToClipboard): 44 (WebCore::Pasteboard::readFromClipboard): 45 (WebCore::Pasteboard::writePlainText): 46 (WebCore::Pasteboard::write): 47 (WebCore::Pasteboard::writePasteboard): 48 (WebCore::Pasteboard::clear): 49 (WebCore::Pasteboard::canSmartReplace): 50 (WebCore::Pasteboard::read): 51 (WebCore::Pasteboard::hasData): 52 (WebCore::Pasteboard::types): 53 (WebCore::Pasteboard::readString): 54 (WebCore::Pasteboard::readFilenames): Made to use the 55 PasteboardStrategy instead of PasteboardHelper/GTK+ API. 56 * platform/gtk/PasteboardHelper.cpp: 57 (WebCore::PasteboardHelper::~PasteboardHelper): 58 (WebCore::ClipboardSetData::ClipboardSetData): 59 (WebCore::clearClipboardContentsCallback): 60 (WebCore::PasteboardHelper::writeClipboardContents): Remove the GClosure 61 to notify whether the global selection has been replaced. Use std:function 62 instead. Remove SmartPasteInclusion argument, now figured out through 63 DataObjectGtk canSmartPaste() member. 64 * platform/gtk/PasteboardHelper.h: 65 * platform/gtk/PlatformPasteboardGtk.cpp: Added. 66 (WebCore::PlatformPasteboard::PlatformPasteboard): 67 (WebCore::PlatformPasteboard::writeToClipboard): 68 (WebCore::PlatformPasteboard::readFromClipboard): Implemented 69 PlatformPasteboard using PasteboardHelper/GTK+ API. 70 1 71 2016-09-13 Carlos Garcia Campos <cgarcia@igalia.com> 2 72 -
releases/WebKitGTK/webkit-2.14/Source/WebCore/PlatformGTK.cmake
r205116 r205959 222 222 platform/gtk/PlatformKeyboardEventGtk.cpp 223 223 platform/gtk/PlatformMouseEventGtk.cpp 224 platform/gtk/PlatformPasteboardGtk.cpp 224 225 platform/gtk/PlatformScreenGtk.cpp 225 226 platform/gtk/PlatformWheelEventGtk.cpp -
releases/WebKitGTK/webkit-2.14/Source/WebCore/editing/gtk/EditorGtk.cpp
r205958 r205959 126 126 pasteboardContent.text = selectedTextForDataTransfer(); 127 127 pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs); 128 pasteboardContent.callback = nullptr;129 128 pasteboard.write(pasteboardContent); 130 129 } -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/Pasteboard.h
r205958 r205959 33 33 #include <wtf/text/WTFString.h> 34 34 35 #if PLATFORM(GTK)36 typedef struct _GtkClipboard GtkClipboard;37 #include <wtf/glib/GRefPtr.h>38 #endif39 40 35 #if PLATFORM(IOS) 41 36 OBJC_CLASS NSArray; … … 84 79 String text; 85 80 String markup; 86 GRefPtr<GClosure> callback;87 81 #endif 88 82 }; … … 144 138 145 139 #if PLATFORM(GTK) 140 explicit Pasteboard(const String& name); 146 141 explicit Pasteboard(RefPtr<DataObjectGtk>&&); 147 explicit Pasteboard(GtkClipboard*);148 142 #endif 149 143 … … 227 221 228 222 #if PLATFORM(GTK) 223 enum class ShouldIncludeSmartPaste { No, Yes }; 224 void writeToClipboard(ShouldIncludeSmartPaste = ShouldIncludeSmartPaste::No); 225 void readFromClipboard(); 229 226 RefPtr<DataObjectGtk> m_dataObject; 230 GtkClipboard* m_gtkClipboard;227 String m_name; 231 228 #endif 232 229 -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/PasteboardStrategy.h
r203109 r205959 39 39 struct PasteboardWebContent; 40 40 41 #if PLATFORM(GTK) 42 class DataObjectGtk; 43 #endif 44 41 45 class PasteboardStrategy { 42 46 public: … … 69 73 virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0; 70 74 #endif 75 #if PLATFORM(GTK) 76 virtual void writeToClipboard(const String& pasteboardName, const RefPtr<DataObjectGtk>&) = 0; 77 virtual RefPtr<DataObjectGtk> readFromClipboard(const String& pasteboardName) = 0; 78 #endif // PLATFORM(GTK) 71 79 protected: 72 80 virtual ~PasteboardStrategy() -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/PlatformPasteboard.h
r203109 r205959 48 48 struct PasteboardWebContent; 49 49 50 #if PLATFORM(GTK) 51 class DataObjectGtk; 52 #endif 53 50 54 class PlatformPasteboard { 51 55 public: … … 82 86 WEBCORE_EXPORT int count(); 83 87 88 #if PLATFORM(GTK) 89 WEBCORE_EXPORT void writeToClipboard(const RefPtr<DataObjectGtk>&, std::function<void()>&& primarySelectionCleared); 90 WEBCORE_EXPORT RefPtr<DataObjectGtk> readFromClipboard(); 91 #endif 92 84 93 private: 85 94 #if PLATFORM(MAC) … … 89 98 RetainPtr<UIPasteboard> m_pasteboard; 90 99 #endif 100 #if PLATFORM(GTK) 101 GtkClipboard* m_clipboard; 102 #endif 91 103 }; 92 104 -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/DataObjectGtk.cpp
r205958 r205959 140 140 m_image = nullptr; 141 141 m_unknownTypeData.clear(); 142 m_canSmartReplace = false; 142 143 } 143 144 -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/DataObjectGtk.h
r205958 r205959 48 48 bool hasFilenames() const { return !m_filenames.isEmpty(); } 49 49 bool hasImage() const { return m_image; } 50 bool canSmartReplace() const { return m_canSmartReplace; } 50 51 void clearURIList() { m_uriList = emptyString(); } 51 52 void clearURL() { m_url = URL(); } … … 60 61 void setUnknownTypeData(const String& type, const String& data) { m_unknownTypeData.set(type, data); } 61 62 void setURIList(const String&); 63 void setCanSmartReplace(bool canSmartReplace) { m_canSmartReplace = canSmartReplace; } 62 64 String urlLabel() const; 63 65 … … 75 77 GRefPtr<GdkPixbuf> m_image; 76 78 HashMap<String, String> m_unknownTypeData; 79 bool m_canSmartReplace { false }; 77 80 }; 78 81 -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r205958 r205959 24 24 #include "DragData.h" 25 25 #include "Image.h" 26 #include "PasteboardStrategy.h" 27 #include "PlatformStrategies.h" 26 28 #include "URL.h" 27 #include "PasteboardHelper.h" 28 #include <gtk/gtk.h> 29 #include <wtf/NeverDestroyed.h> 29 30 30 31 namespace WebCore { … … 41 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 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 … … 77 78 Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject) 78 79 : m_dataObject(WTFMove(dataObject)) 79 , m_gtkClipboard(nullptr)80 80 { 81 81 ASSERT(m_dataObject); 82 82 } 83 83 84 Pasteboard::Pasteboard( GtkClipboard* gtkClipboard)84 Pasteboard::Pasteboard(const String& name) 85 85 : m_dataObject(DataObjectGtk::create()) 86 , m_gtkClipboard(gtkClipboard) 87 { 88 ASSERT(m_dataObject); 89 PasteboardHelper::singleton().registerClipboard(gtkClipboard); 86 , m_name(name) 87 { 90 88 } 91 89 … … 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 137 void Pasteboard::writeString(const String& type, const String& data) 125 138 { … … 148 161 m_dataObject->setText(text); 149 162 150 if (m_gtkClipboard) 151 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject, (smartReplaceOption == CanSmartReplace) ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste); 163 writeToClipboard(smartReplaceOption == CanSmartReplace ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No); 152 164 } 153 165 … … 159 171 m_dataObject->setURL(pasteboardURL.url, pasteboardURL.title); 160 172 161 if (m_gtkClipboard) 162 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); 173 writeToClipboard(); 163 174 } 164 175 … … 175 186 m_dataObject->setImage(pixbuf.get()); 176 187 177 if (m_gtkClipboard) 178 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); 188 writeToClipboard(); 179 189 } 180 190 … … 185 195 m_dataObject->setMarkup(pasteboardContent.markup); 186 196 187 if (m_gtkClipboard) 188 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject, pasteboardContent.canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste, pasteboardContent.callback.get()); 197 writeToClipboard(pasteboardContent.canSmartCopyOrDelete ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No); 189 198 } 190 199 … … 209 218 } 210 219 211 if (m_gtkClipboard) 212 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); 220 writeToClipboard(); 213 221 } 214 222 … … 220 228 // still contain the "Files" string if any files were included in the drag)." 221 229 m_dataObject->clearAllExceptFilenames(); 222 223 if (m_gtkClipboard) 224 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); 230 writeToClipboard(); 225 231 } 226 232 … … 246 252 } 247 253 248 if (m_gtkClipboard) 249 PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject); 254 writeToClipboard(); 250 255 } 251 256 252 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 … … 263 269 void Pasteboard::read(PasteboardPlainText& text) 264 270 { 265 if (m_gtkClipboard) 266 PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); 271 readFromClipboard(); 267 272 text.text = m_dataObject->text(); 268 273 } … … 270 275 bool Pasteboard::hasData() 271 276 { 272 if (m_gtkClipboard) 273 PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); 274 277 readFromClipboard(); 275 278 return m_dataObject->hasText() || m_dataObject->hasMarkup() || m_dataObject->hasURIList() || m_dataObject->hasImage() || m_dataObject->hasUnknownTypeData(); 276 279 } … … 278 281 Vector<String> Pasteboard::types() 279 282 { 280 if (m_gtkClipboard) 281 PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); 283 readFromClipboard(); 282 284 283 285 Vector<String> types; … … 307 309 String Pasteboard::readString(const String& type) 308 310 { 309 if (m_gtkClipboard) 310 PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); 311 readFromClipboard(); 311 312 312 313 switch (dataObjectTypeFromHTMLClipboardType(type)) { … … 330 331 Vector<String> Pasteboard::readFilenames() 331 332 { 332 if (m_gtkClipboard) 333 PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject); 334 333 readFromClipboard(); 335 334 return m_dataObject->filenames(); 336 335 } -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/PasteboardHelper.cpp
r205958 r205959 77 77 PasteboardHelper::~PasteboardHelper() 78 78 { 79 for (auto* clipboard : m_gtkClipboards)80 gtk_clipboard_store(clipboard);81 79 } 82 80 … … 116 114 } 117 115 } 116 117 dataObject.setCanSmartReplace(gtk_clipboard_wait_is_target_available(clipboard, smartPasteAtom)); 118 118 } 119 119 … … 170 170 } 171 171 172 GRefPtr<GtkTargetList> PasteboardHelper::targetListForDataObject(const DataObjectGtk& dataObject , SmartPasteInclusion shouldInludeSmartPaste)172 GRefPtr<GtkTargetList> PasteboardHelper::targetListForDataObject(const DataObjectGtk& dataObject) 173 173 { 174 174 GRefPtr<GtkTargetList> list = adoptGRef(gtk_target_list_new(nullptr, 0)); … … 191 191 gtk_target_list_add(list.get(), unknownAtom, 0, TargetTypeUnknown); 192 192 193 if ( shouldInludeSmartPaste == IncludeSmartPaste)193 if (dataObject.canSmartReplace()) 194 194 gtk_target_list_add(list.get(), smartPasteAtom, 0, TargetTypeSmartPaste); 195 195 … … 258 258 259 259 struct ClipboardSetData { 260 ClipboardSetData(DataObjectGtk* dataObject, GClosure* callback)260 ClipboardSetData(DataObjectGtk* dataObject, std::function<void()>&& selectionClearedCallback) 261 261 : dataObject(dataObject) 262 , callback(callback)262 , selectionClearedCallback(WTFMove(selectionClearedCallback)) 263 263 { 264 264 } … … 269 269 270 270 RefPtr<DataObjectGtk> dataObject; 271 GRefPtr<GClosure> callback;271 std::function<void()> selectionClearedCallback; 272 272 }; 273 273 … … 278 278 } 279 279 280 static void clearClipboardContentsCallback(GtkClipboard* clipboard, gpointer userData)280 static void clearClipboardContentsCallback(GtkClipboard*, gpointer userData) 281 281 { 282 282 std::unique_ptr<ClipboardSetData> data(static_cast<ClipboardSetData*>(userData)); … … 286 286 data->dataObject->clearAll(); 287 287 288 if (!data->callback) 289 return; 290 291 GValue firstArgument = {0, {{0}}}; 292 g_value_init(&firstArgument, G_TYPE_POINTER); 293 g_value_set_pointer(&firstArgument, clipboard); 294 g_closure_invoke(data->callback.get(), nullptr, 1, &firstArgument, 0); 295 } 296 297 void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, const DataObjectGtk& dataObject, SmartPasteInclusion includeSmartPaste, GClosure* callback) 298 { 299 GRefPtr<GtkTargetList> list = targetListForDataObject(dataObject, includeSmartPaste); 288 if (data->selectionClearedCallback) 289 data->selectionClearedCallback(); 290 } 291 292 void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, const DataObjectGtk& dataObject, std::function<void()>&& primarySelectionCleared) 293 { 294 GRefPtr<GtkTargetList> list = targetListForDataObject(dataObject); 300 295 301 296 int numberOfTargets; … … 305 300 settingClipboardDataObject = const_cast<DataObjectGtk*>(&dataObject); 306 301 307 auto data = std::make_unique<ClipboardSetData>(settingClipboardDataObject, callback);302 auto data = std::make_unique<ClipboardSetData>(settingClipboardDataObject, WTFMove(primarySelectionCleared)); 308 303 if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, data.get())) { 309 304 gtk_clipboard_set_can_store(clipboard, nullptr, 0); … … 320 315 } 321 316 322 bool PasteboardHelper::clipboardContentSupportsSmartReplace(GtkClipboard* clipboard) 323 { 324 return gtk_clipboard_wait_is_target_available(clipboard, smartPasteAtom); 325 } 326 327 void PasteboardHelper::registerClipboard(GtkClipboard* clipboard) 328 { 329 ASSERT(clipboard); 330 m_gtkClipboards.add(clipboard); 331 } 332 333 } 334 317 } 318 -
releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/gtk/PasteboardHelper.h
r205958 r205959 27 27 28 28 #include "GRefPtrGtk.h" 29 #include <wtf/HashSet.h>30 29 #include <wtf/Noncopyable.h> 31 30 #include <wtf/Vector.h> … … 44 43 45 44 GtkTargetList* targetList() const; 46 GRefPtr<GtkTargetList> targetListForDataObject(const DataObjectGtk& , SmartPasteInclusion = DoNotIncludeSmartPaste);45 GRefPtr<GtkTargetList> targetListForDataObject(const DataObjectGtk&); 47 46 void fillSelectionData(GtkSelectionData*, guint, const DataObjectGtk&); 48 47 void fillDataObjectFromDropData(GtkSelectionData*, guint, DataObjectGtk&); 49 48 Vector<GdkAtom> dropAtomsForContext(GtkWidget*, GdkDragContext*); 50 void writeClipboardContents(GtkClipboard*, const DataObjectGtk&, SmartPasteInclusion = DoNotIncludeSmartPaste, GClosure* = 0);49 void writeClipboardContents(GtkClipboard*, const DataObjectGtk&, std::function<void()>&& primarySelectionCleared = nullptr); 51 50 void getClipboardContents(GtkClipboard*, DataObjectGtk&); 52 51 53 52 enum PasteboardTargetType { TargetTypeMarkup, TargetTypeText, TargetTypeImage, TargetTypeURIList, TargetTypeNetscapeURL, TargetTypeSmartPaste, TargetTypeUnknown }; 54 bool clipboardContentSupportsSmartReplace(GtkClipboard*);55 56 void registerClipboard(GtkClipboard*);57 53 58 54 private: … … 61 57 62 58 GRefPtr<GtkTargetList> m_targetList; 63 HashSet<GtkClipboard*> m_gtkClipboards;64 59 }; 65 60 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/ChangeLog
r205958 r205959 1 2016-09-14 Carlos Garnacho <carlosg@gnome.org> 2 3 [GTK][Wayland] Implement clipboard support 4 https://bugs.webkit.org/show_bug.cgi?id=146574 5 6 Reviewed by Carlos Garcia Campos. 7 8 Add the necessary plumbing for the GTK+ backend to use the 9 PlatformPasteboard in WebCore. All selection data is transmitted 10 at once through the serialization of PasteboardContentGtk/DataObjectGtk. 11 12 * PlatformGTK.cmake: Add PasteboardContentGtk.cpp and 13 WebPasteboardProxyGtk.cpp 14 * Shared/gtk/ArgumentCodersGtk.cpp: 15 (IPC::encode): 16 (IPC::decode): Renamed from encodeDataObject/decodeDataObject 17 and made public. 18 (IPC::ArgumentCoder<DragData>::encode): 19 (IPC::ArgumentCoder<DragData>::decode): Update DataObjectGtk 20 encode/decode callers. Encode the extra canSmartReplace field. 21 * Shared/gtk/ArgumentCodersGtk.h: Expose encode/decode methods for 22 DataObjectGtk. 23 * Shared/gtk/PasteboardContent.cpp: Added. Wraps a DataObjectGtk 24 so it can be serialized on WebProcess/UIProcess messaging. 25 (WebKit::PasteboardContent::PasteboardContent): 26 (WebKit::PasteboardContent::encode): 27 (WebKit::PasteboardContent::decode): Methods to encode/decode a 28 PasteboardContent. 29 * Shared/gtk/PasteboardContent.h: Added. 30 * UIProcess/WebFrameProxy.cpp: 31 (WebKit::WebFrameProxy::collapseSelection): Added plumbing to allow 32 collapsing the global selection from the UI process side. 33 * UIProcess/WebFrameProxy.h: 34 * UIProcess/WebPasteboardProxy.h: 35 * UIProcess/WebPasteboardProxy.messages.in: Added plumbing for the 36 GTK+ pasteboard proxy functions. 37 * UIProcess/gtk/WebPageProxyGtk.cpp: 38 (WebKit::WebPageProxy::editorStateChanged): 39 * UIProcess/gtk/WebPasteboardProxyGtk.cpp: Added. 40 (WebKit::WebPasteboardProxy::writeToClipboard): 41 (WebKit::WebPasteboardProxy::readFromClipboard): Implemented functions 42 hooking into the PlatformPasteboard. Per-selection (ie. 43 primary/clipboard) PlatformPasteboards are kept at this level, so those 44 are independently set and dealt with. 45 (WebKit::WebPasteboardProxy::setPrimarySelectionOwner): 46 (WebKit::WebPasteboardProxy::didDestroyFrame): Implemented functions 47 to manage the frame currently being currently interacted, so we can 48 signal back when the global selection has been replaced. 49 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 50 (WebKit::WebPlatformStrategies::writeToClipboard): 51 (WebKit::WebPlatformStrategies::readFromClipboard): Added methods to 52 send the WebProcess->UIProcess messages. 53 * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 54 * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp: 55 (WebKit::WebEditorClient::updateGlobalSelection): Remove GClosure to 56 get notifications about changes in global selection ownership. This 57 is done through a WebPage message now, as the UI process manages the 58 clipboard. 59 * WebProcess/WebPage/WebPage.h: 60 * WebProcess/WebPage/WebPage.messages.in: 61 * WebProcess/WebPage/gtk/WebPageGtk.cpp: 62 (WebKit::WebPage::collapseSelectionInFrame): Added methods to send 63 the UIProcess->WebProcess notification that the global selection has 64 been replaced. 65 1 66 2016-09-13 Carlos Garcia Campos <cgarcia@igalia.com> 2 67 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/PlatformGTK.cmake
r205622 r205959 71 71 Shared/gtk/NativeWebTouchEventGtk.cpp 72 72 Shared/gtk/NativeWebWheelEventGtk.cpp 73 Shared/gtk/PasteboardContent.cpp 73 74 Shared/gtk/PrintInfoGtk.cpp 74 75 Shared/gtk/ProcessExecutablePathGtk.cpp … … 312 313 UIProcess/gtk/WebInspectorProxyGtk.cpp 313 314 UIProcess/gtk/WebPageProxyGtk.cpp 315 UIProcess/gtk/WebPasteboardProxyGtk.cpp 314 316 UIProcess/gtk/WebPopupMenuProxyGtk.cpp 315 317 UIProcess/gtk/WebPreferencesGtk.cpp -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp
r204678 r205959 83 83 } 84 84 85 static void encodeDataObject(Encoder& encoder, const DataObjectGtk* dataObject)85 void encode(Encoder& encoder, const DataObjectGtk* dataObject) 86 86 { 87 87 bool hasText = dataObject->hasText(); … … 114 114 if (hasUnknownTypeData) 115 115 encoder << dataObject->unknownTypes(); 116 } 117 118 static bool decodeDataObject(Decoder& decoder, RefPtr<DataObjectGtk>& dataObject) 116 117 bool canSmartReplace = dataObject->canSmartReplace(); 118 encoder << canSmartReplace; 119 } 120 121 bool decode(Decoder& decoder, RefPtr<DataObjectGtk>& dataObject) 119 122 { 120 123 RefPtr<DataObjectGtk> data = DataObjectGtk::create(); … … 182 185 data->setUnknownTypeData(it->key, it->value); 183 186 } 187 188 bool canSmartReplace; 189 if (!decoder.decode(canSmartReplace)) 190 return false; 191 data->setCanSmartReplace(canSmartReplace); 184 192 185 193 dataObject = data; … … 199 207 encoder << static_cast<bool>(platformData); 200 208 if (platformData) 201 encodeDataObject(encoder, platformData);209 IPC::encode(encoder, platformData); 202 210 } 203 211 … … 226 234 RefPtr<DataObjectGtk> platformData; 227 235 if (hasPlatformData) { 228 if (! decodeDataObject(decoder, platformData))236 if (!IPC::decode(decoder, platformData)) 229 237 return false; 230 238 } -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h
r204678 r205959 53 53 bool decode(Decoder&, GRefPtr<GtkPageSetup>&); 54 54 55 void encode(Encoder&, const WebCore::DataObjectGtk*); 56 bool decode(Decoder&, RefPtr<WebCore::DataObjectGtk>&); 57 55 58 } // namespace IPC 56 59 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/WebFrameProxy.cpp
r191063 r205959 32 32 #include "WebPageMessages.h" 33 33 #include "WebPageProxy.h" 34 #include "WebPasteboardProxy.h" 34 35 #include "WebProcessPool.h" 35 36 #include <WebCore/DOMImplementation.h> … … 54 55 { 55 56 WebProcessPool::statistics().wkFrameCount--; 57 #if PLATFORM(GTK) 58 WebPasteboardProxy::singleton().didDestroyFrame(this); 59 #endif 56 60 } 57 61 … … 258 262 #endif 259 263 264 #if PLATFORM(GTK) 265 void WebFrameProxy::collapseSelection() 266 { 267 if (!m_page) 268 return; 269 270 m_page->process().send(Messages::WebPage::CollapseSelectionInFrame(m_frameID), m_page->pageID()); 271 } 272 #endif 273 260 274 } // namespace WebKit -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/WebFrameProxy.h
r204668 r205959 125 125 #endif 126 126 127 #if PLATFORM(GTK) 128 void collapseSelection(); 129 #endif 130 127 131 private: 128 132 WebFrameProxy(WebPageProxy* page, uint64_t frameID); -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/WebPasteboardProxy.h
r204668 r205959 41 41 namespace WebKit { 42 42 43 class WebFrameProxy; 43 44 class WebProcessProxy; 45 46 #if PLATFORM(GTK) 47 class PasteboardContent; 48 #endif 44 49 45 50 class WebPasteboardProxy : public IPC::MessageReceiver { … … 50 55 51 56 void addWebProcessProxy(WebProcessProxy&); 57 58 #if PLATFORM(GTK) 59 void setPrimarySelectionOwner(WebFrameProxy*); 60 void didDestroyFrame(WebFrameProxy*); 61 #endif 52 62 53 63 private: … … 82 92 void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount); 83 93 #endif 94 #if PLATFORM(GTK) 95 void writeToClipboard(const String& pasteboardName, const PasteboardContent&); 96 void readFromClipboard(const String& pasteboardName, PasteboardContent&); 97 98 WebFrameProxy* m_primarySelectionOwner { nullptr }; 99 WebFrameProxy* m_frameWritingToClipboard { nullptr }; 100 #endif // PLATFORM(GTK) 84 101 }; 85 102 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in
r177805 r205959 49 49 SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (uint64_t changeCount) 50 50 #endif 51 52 #if PLATFORM(GTK) 53 WriteToClipboard(String pasteboardName, struct WebKit::PasteboardContent pasteboardContent) 54 ReadFromClipboard(String pasteboardName) -> (struct WebKit::PasteboardContent pasteboardContent) 55 #endif 51 56 } -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
r191628 r205959 32 32 #include "WebKitWebViewBasePrivate.h" 33 33 #include "WebPageMessages.h" 34 #include "WebPasteboardProxy.h" 34 35 #include "WebProcessProxy.h" 35 36 #include "WebsiteDataStore.h" … … 80 81 if (editorState.shouldIgnoreCompositionSelectionChange) 81 82 return; 83 if (m_editorState.selectionIsRange) 84 WebPasteboardProxy::singleton().setPrimarySelectionOwner(focusedFrame()); 82 85 m_pageClient.selectionDidChange(); 83 86 } -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r204327 r205959 70 70 #endif 71 71 72 #if PLATFORM(GTK) 73 #include "PasteboardContent.h" 74 #endif 75 72 76 using namespace WebCore; 73 77 … … 340 344 #endif // PLATFORM(COCOA) 341 345 346 #if PLATFORM(GTK) 347 // PasteboardStrategy 348 349 void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>& dataObject) 350 { 351 PasteboardContent pasteboardContent = PasteboardContent(dataObject.get()); 352 WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, pasteboardContent), 0); 353 } 354 355 RefPtr<WebCore::DataObjectGtk> WebPlatformStrategies::readFromClipboard(const String& pasteboardName) 356 { 357 PasteboardContent pasteboardContent; 358 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadFromClipboard(pasteboardName), Messages::WebPasteboardProxy::ReadFromClipboard::Reply(pasteboardContent), 0); 359 return pasteboardContent.dataObject; 360 } 361 362 #endif // PLATFORM(GTK) 363 342 364 } // namespace WebKit -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
r204466 r205959 87 87 long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override; 88 88 #endif 89 89 #if PLATFORM(GTK) 90 void writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>&) override; 91 RefPtr<WebCore::DataObjectGtk> readFromClipboard(const String& pasteboardName) override; 92 #endif 90 93 }; 91 94 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp
r205958 r205959 120 120 } 121 121 122 class EditorClientFrameDestructionObserver : FrameDestructionObserver {123 public:124 EditorClientFrameDestructionObserver(Frame* frame, GClosure* closure)125 : FrameDestructionObserver(frame)126 , m_closure(closure)127 {128 g_closure_add_finalize_notifier(m_closure, this, destroyOnClosureFinalization);129 }130 131 void frameDestroyed()132 {133 g_closure_invalidate(m_closure);134 FrameDestructionObserver::frameDestroyed();135 }136 private:137 GClosure* m_closure;138 139 static void destroyOnClosureFinalization(gpointer data, GClosure*)140 {141 // Calling delete void* will free the memory but won't invoke142 // the destructor, something that is a must for us.143 EditorClientFrameDestructionObserver* observer = static_cast<EditorClientFrameDestructionObserver*>(data);144 delete observer;145 }146 };147 148 static Frame* frameSettingClipboard;149 150 static void collapseSelection(GtkClipboard*, Frame* frame)151 {152 if (frameSettingClipboard && frameSettingClipboard == frame)153 return;154 155 // Collapse the selection without clearing it.156 ASSERT(frame);157 const VisibleSelection& selection = frame->selection().selection();158 frame->selection().setBase(selection.extent(), selection.affinity());159 }160 161 122 void WebEditorClient::updateGlobalSelection(Frame* frame) 162 123 { … … 167 128 return; 168 129 169 frameSettingClipboard = frame;170 GRefPtr<GClosure> callback = adoptGRef(g_cclosure_new(G_CALLBACK(collapseSelection), frame, nullptr));171 // This observer will be self-destroyed on closure finalization,172 // that will happen either after closure execution or after173 // closure invalidation.174 new EditorClientFrameDestructionObserver(frame, callback.get());175 g_closure_set_marshal(callback.get(), g_cclosure_marshal_VOID__VOID);176 177 130 PasteboardWebContent pasteboardContent; 178 131 pasteboardContent.canSmartCopyOrDelete = false; 179 132 pasteboardContent.text = range->text(); 180 133 pasteboardContent.markup = createMarkup(*range, nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs); 181 pasteboardContent.callback = callback;182 134 Pasteboard::createForGlobalSelection()->write(pasteboardContent); 183 frameSettingClipboard = nullptr;184 135 } 185 136 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/WebPage/WebPage.h
r205733 r205959 644 644 void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength); 645 645 void cancelComposition(); 646 647 void collapseSelectionInFrame(uint64_t frameID); 646 648 #endif 647 649 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r204318 r205959 341 341 ConfirmComposition(String text, int64_t selectionStart, int64_t selectionLength) 342 342 CancelComposition() 343 344 CollapseSelectionInFrame(uint64_t frameID) 343 345 #endif 344 346 -
releases/WebKitGTK/webkit-2.14/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp
r187100 r205959 32 32 #include "NotImplemented.h" 33 33 #include "WebEvent.h" 34 #include "WebFrame.h" 34 35 #include "WebPageAccessibilityObject.h" 35 36 #include "WebPageProxyMessages.h" 37 #include "WebProcess.h" 36 38 #include "WindowsKeyboardCodes.h" 37 39 #include <WebCore/BackForwardController.h> … … 217 219 } 218 220 221 void WebPage::collapseSelectionInFrame(uint64_t frameID) 222 { 223 WebFrame* frame = WebProcess::singleton().webFrame(frameID); 224 if (!frame || !frame->coreFrame()) 225 return; 226 227 // Collapse the selection without clearing it. 228 const VisibleSelection& selection = frame->coreFrame()->selection().selection(); 229 frame->coreFrame()->selection().setBase(selection.extent(), selection.affinity()); 230 } 231 219 232 } // namespace WebKit
Note: See TracChangeset
for help on using the changeset viewer.