Changeset 206197 in webkit
- Timestamp:
- Sep 20, 2016 11:17:13 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206196 r206197 1 2016-09-20 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Clean up DataObjectGtk handling 4 https://bugs.webkit.org/show_bug.cgi?id=162267 5 6 Reviewed by Michael Catanzaro. 7 8 * platform/Pasteboard.h: Use Ref instead of RefPtr for DataObjectGtk member. 9 * platform/PasteboardStrategy.h: Pass a const reference to DataObjectGtk in write method and return a Ref from read. 10 * platform/PlatformPasteboard.h: Ditto. 11 * platform/gtk/DataObjectGtk.h: 12 (WebCore::DataObjectGtk::image): Use Image instead of GdkPixbuf. 13 (WebCore::DataObjectGtk::setImage): 14 * platform/gtk/PasteboardGtk.cpp: 15 (WebCore::Pasteboard::createForDragAndDrop): Use a reference instead of a pointer. 16 (WebCore::Pasteboard::Pasteboard): Receives a reference, so we can also remove the ASSERT. 17 (WebCore::Pasteboard::dataObject): 18 (WebCore::Pasteboard::writeToClipboard): Remove the ShouldIncludeSmartPaste parameter, callers should also update 19 canSmartPaste property of DataObjectGtk before calling this. 20 (WebCore::Pasteboard::writePlainText): 21 (WebCore::Pasteboard::write): Do not convert the image the GdkPixbuf, pass the image to the DataObjectGtk instead. 22 * platform/gtk/PasteboardHelper.cpp: 23 (WebCore::PasteboardHelper::fillSelectionData): Convert the DataObjectGtk image to GdkPixbuf right before 24 passing it to gtk_selection_data_set_pixbuf(). 25 (WebCore::ClipboardSetData::ClipboardSetData): Use reference instead of pointer. 26 (WebCore::getClipboardContentsCallback): 27 (WebCore::clearClipboardContentsCallback): Never clear the saved DataObjectGtk, that was only needed when we had 28 a global DataObjectGtk associated to a GtkClipboard. 29 (WebCore::PasteboardHelper::writeClipboardContents): Use TemporaryChange to set the settingClipboardDataObject global. 30 * platform/gtk/PlatformPasteboardGtk.cpp: 31 (WebCore::PlatformPasteboard::writeToClipboard): 32 (WebCore::PlatformPasteboard::readFromClipboard): 33 1 34 2016-09-20 Alex Christensen <achristensen@webkit.org> 2 35 -
trunk/Source/WebCore/platform/Pasteboard.h
r205909 r206197 139 139 #if PLATFORM(GTK) 140 140 explicit Pasteboard(const String& name); 141 explicit Pasteboard( RefPtr<DataObjectGtk>&&);141 explicit Pasteboard(DataObjectGtk&); 142 142 #endif 143 143 … … 221 221 222 222 #if PLATFORM(GTK) 223 enum class ShouldIncludeSmartPaste { No, Yes }; 224 void writeToClipboard(ShouldIncludeSmartPaste = ShouldIncludeSmartPaste::No); 223 void writeToClipboard(); 225 224 void readFromClipboard(); 226 Ref Ptr<DataObjectGtk> m_dataObject;225 Ref<DataObjectGtk> m_dataObject; 227 226 String m_name; 228 227 #endif -
trunk/Source/WebCore/platform/PasteboardStrategy.h
r205909 r206197 74 74 #endif 75 75 #if PLATFORM(GTK) 76 virtual void writeToClipboard(const String& pasteboardName, const RefPtr<DataObjectGtk>&) = 0;77 virtual Ref Ptr<DataObjectGtk> readFromClipboard(const String& pasteboardName) = 0;76 virtual void writeToClipboard(const String& pasteboardName, const DataObjectGtk&) = 0; 77 virtual Ref<DataObjectGtk> readFromClipboard(const String& pasteboardName) = 0; 78 78 #endif // PLATFORM(GTK) 79 79 protected: -
trunk/Source/WebCore/platform/PlatformPasteboard.h
r205909 r206197 87 87 88 88 #if PLATFORM(GTK) 89 WEBCORE_EXPORT void writeToClipboard(const RefPtr<DataObjectGtk>&, std::function<void()>&& primarySelectionCleared);90 WEBCORE_EXPORT Ref Ptr<DataObjectGtk> readFromClipboard();89 WEBCORE_EXPORT void writeToClipboard(const DataObjectGtk&, std::function<void()>&& primarySelectionCleared); 90 WEBCORE_EXPORT Ref<DataObjectGtk> readFromClipboard(); 91 91 #endif 92 92 -
trunk/Source/WebCore/platform/gtk/DataObjectGtk.h
r205909 r206197 19 19 #pragma once 20 20 21 #include " FileList.h"21 #include "Image.h" 22 22 #include "URL.h" 23 23 #include <wtf/HashMap.h> 24 24 #include <wtf/RefCounted.h> 25 #include <wtf/glib/GRefPtr.h>26 25 #include <wtf/text/StringHash.h> 27 26 … … 38 37 const String& uriList() const { return m_uriList; } 39 38 const Vector<String>& filenames() const { return m_filenames; } 40 GdkPixbuf* image() const { return m_image.get(); }41 void setImage( GdkPixbuf* newImage) { m_image = newImage; }39 Image* image() const { return m_image.get(); } 40 void setImage(Image* newImage) { m_image = newImage; } 42 41 void setURL(const URL&, const String&); 43 42 bool hasUnknownTypeData() const { return !m_unknownTypeData.isEmpty(); } … … 75 74 String m_uriList; 76 75 Vector<String> m_filenames; 77 GRefPtr<GdkPixbuf> m_image;76 RefPtr<Image> m_image; 78 77 HashMap<String, String> m_unknownTypeData; 79 78 bool m_canSmartReplace { false }; -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r205909 r206197 63 63 std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData) 64 64 { 65 return std::make_unique<Pasteboard>(dragData.platformData()); 65 ASSERT(dragData.platformData()); 66 return std::make_unique<Pasteboard>(*dragData.platformData()); 66 67 } 67 68 #endif … … 76 77 } 77 78 78 Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject) 79 : m_dataObject(WTFMove(dataObject)) 80 { 81 ASSERT(m_dataObject); 79 Pasteboard::Pasteboard(DataObjectGtk& dataObject) 80 : m_dataObject(dataObject) 81 { 82 82 } 83 83 … … 94 94 const DataObjectGtk& Pasteboard::dataObject() const 95 95 { 96 return *m_dataObject;96 return m_dataObject.get(); 97 97 } 98 98 … … 120 120 } 121 121 122 void Pasteboard::writeToClipboard( ShouldIncludeSmartPaste shouldIncludeSmartPaste)122 void Pasteboard::writeToClipboard() 123 123 { 124 124 if (m_name.isNull()) 125 125 return; 126 m_dataObject->setCanSmartReplace(shouldIncludeSmartPaste == ShouldIncludeSmartPaste::Yes); 126 127 127 platformStrategies()->pasteboardStrategy()->writeToClipboard(m_name, m_dataObject); 128 128 } … … 160 160 m_dataObject->clearAll(); 161 161 m_dataObject->setText(text); 162 163 writeToClipboard(smartReplaceOption == CanSmartReplace ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No); 162 m_dataObject->setCanSmartReplace(smartReplaceOption == CanSmartReplace); 163 164 writeToClipboard(); 164 165 } 165 166 … … 181 182 m_dataObject->setMarkup(pasteboardImage.url.markup); 182 183 } 183 184 GRefPtr<GdkPixbuf> pixbuf = adoptGRef(pasteboardImage.image->getGdkPixbuf()); 185 if (pixbuf) 186 m_dataObject->setImage(pixbuf.get()); 184 m_dataObject->setImage(pasteboardImage.image.get()); 187 185 188 186 writeToClipboard(); … … 194 192 m_dataObject->setText(pasteboardContent.text); 195 193 m_dataObject->setMarkup(pasteboardContent.markup); 196 197 writeToClipboard(pasteboardContent.canSmartCopyOrDelete ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No); 194 m_dataObject->setCanSmartReplace(pasteboardContent.canSmartCopyOrDelete); 195 196 writeToClipboard(); 198 197 } 199 198 -
trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp
r205909 r206197 26 26 #include "DataObjectGtk.h" 27 27 #include "GtkVersioning.h" 28 #include "Pasteboard.h"29 #include "TextResourceDecoder.h"30 28 #include <gtk/gtk.h> 29 #include <wtf/TemporaryChange.h> 31 30 #include <wtf/glib/GUniquePtr.h> 32 31 #include <wtf/text/CString.h> … … 149 148 reinterpret_cast<const guchar*>(resultData.get()), strlen(resultData.get())); 150 149 151 } else if (info == TargetTypeImage) 152 gtk_selection_data_set_pixbuf(selectionData, dataObject.image()); 153 154 else if (info == TargetTypeSmartPaste) 150 } else if (info == TargetTypeImage && dataObject.hasImage()) { 151 GRefPtr<GdkPixbuf> pixbuf = adoptGRef(dataObject.image()->getGdkPixbuf()); 152 gtk_selection_data_set_pixbuf(selectionData, pixbuf.get()); 153 154 } else if (info == TargetTypeSmartPaste) 155 155 gtk_selection_data_set_text(selectionData, "", -1); 156 156 … … 258 258 259 259 struct ClipboardSetData { 260 ClipboardSetData(DataObjectGtk *dataObject, std::function<void()>&& selectionClearedCallback)260 ClipboardSetData(DataObjectGtk& dataObject, std::function<void()>&& selectionClearedCallback) 261 261 : dataObject(dataObject) 262 262 , selectionClearedCallback(WTFMove(selectionClearedCallback)) … … 268 268 } 269 269 270 Ref Ptr<DataObjectGtk> dataObject;270 Ref<DataObjectGtk> dataObject; 271 271 std::function<void()> selectionClearedCallback; 272 272 }; … … 275 275 { 276 276 auto* data = static_cast<ClipboardSetData*>(userData); 277 PasteboardHelper::singleton().fillSelectionData(selectionData, info, *data->dataObject);277 PasteboardHelper::singleton().fillSelectionData(selectionData, info, data->dataObject); 278 278 } 279 279 … … 281 281 { 282 282 std::unique_ptr<ClipboardSetData> data(static_cast<ClipboardSetData*>(userData)); 283 284 // Only clear the DataObject for this clipboard if we are not currently setting it.285 if (data->dataObject.get() != settingClipboardDataObject)286 data->dataObject->clearAll();287 288 283 if (data->selectionClearedCallback) 289 284 data->selectionClearedCallback(); … … 298 293 299 294 if (numberOfTargets > 0 && table) { 300 settingClipboardDataObject = const_cast<DataObjectGtk*>(&dataObject); 301 302 auto data = std::make_unique<ClipboardSetData>(settingClipboardDataObject, WTFMove(primarySelectionCleared)); 295 TemporaryChange<DataObjectGtk*> change(settingClipboardDataObject, const_cast<DataObjectGtk*>(&dataObject)); 296 auto data = std::make_unique<ClipboardSetData>(*settingClipboardDataObject, WTFMove(primarySelectionCleared)); 303 297 if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, data.get())) { 304 298 gtk_clipboard_set_can_store(clipboard, nullptr, 0); … … 306 300 data.release(); 307 301 } 308 309 settingClipboardDataObject = nullptr;310 302 } else 311 303 gtk_clipboard_clear(clipboard); -
trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp
r205909 r206197 35 35 } 36 36 37 void PlatformPasteboard::writeToClipboard(const RefPtr<DataObjectGtk>& dataObject, std::function<void()>&& primarySelectionCleared)37 void PlatformPasteboard::writeToClipboard(const DataObjectGtk& dataObject, std::function<void()>&& primarySelectionCleared) 38 38 { 39 PasteboardHelper::singleton().writeClipboardContents(m_clipboard, *dataObject, gtk_clipboard_get(GDK_SELECTION_PRIMARY) == m_clipboard ? WTFMove(primarySelectionCleared) : nullptr);39 PasteboardHelper::singleton().writeClipboardContents(m_clipboard, dataObject, gtk_clipboard_get(GDK_SELECTION_PRIMARY) == m_clipboard ? WTFMove(primarySelectionCleared) : nullptr); 40 40 } 41 41 42 Ref Ptr<DataObjectGtk> PlatformPasteboard::readFromClipboard()42 Ref<DataObjectGtk> PlatformPasteboard::readFromClipboard() 43 43 { 44 Ref Ptr<DataObjectGtk> dataObject = DataObjectGtk::create();45 PasteboardHelper::singleton().getClipboardContents(m_clipboard, *dataObject);44 Ref<DataObjectGtk> dataObject(DataObjectGtk::create()); 45 PasteboardHelper::singleton().getClipboardContents(m_clipboard, dataObject.get()); 46 46 return dataObject; 47 47 } -
trunk/Source/WebKit2/ChangeLog
r206194 r206197 1 2016-09-20 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Clean up DataObjectGtk handling 4 https://bugs.webkit.org/show_bug.cgi?id=162267 5 6 Reviewed by Michael Catanzaro. 7 8 In some cases the ownership of DataObjectGtk instances is not clear enough, and we have hacks to avoid memory 9 leaks because of that. 10 11 * Shared/gtk/ArgumentCodersGtk.cpp: 12 (IPC::encodeImage): Use Image instead of GdkPixbuf. 13 (IPC::decodeImage): Ditto. 14 (IPC::ArgumentCoder<DataObjectGtk>::encode): 15 (IPC::ArgumentCoder<DataObjectGtk>::decode): 16 (IPC::encode): Deleted. 17 (IPC::decode): Deleted. 18 (IPC::ArgumentCoder<DragData>::encode): Deleted. 19 (IPC::ArgumentCoder<DragData>::decode): Deleted. 20 * Shared/gtk/ArgumentCodersGtk.h: 21 * Shared/gtk/PasteboardContent.cpp: 22 (WebKit::PasteboardContent::PasteboardContent): Add empty constructor that creates a new DataObjectGtk, a 23 constructor that receives a const reference and another one that takes the ownership of the given DataObjectGtk. 24 (WebKit::PasteboardContent::encode): 25 (WebKit::PasteboardContent::decode): 26 * Shared/gtk/PasteboardContent.h: Use Ref instead of RefPtr for the DataObjectGtk member. 27 * UIProcess/API/gtk/PageClientImpl.cpp: 28 (WebKit::PageClientImpl::startDrag): Transfer the DataObjectGtk to the DragAndDropHandler, instead of using DragData. 29 * UIProcess/API/gtk/PageClientImpl.h: 30 * UIProcess/PageClient.h: 31 * UIProcess/WebPageProxy.cpp: 32 (WebKit::WebPageProxy::performDragControllerAction): Instead of sending a DragData object to the web process, 33 send the DataObjectGtk and DragData members needed as parameters. 34 (WebKit::WebPageProxy::startDrag): Transfer the received DataObjectGtk to page client, instead of using 35 DragData. Also notify the web process that drag started. 36 * UIProcess/WebPageProxy.h: 37 * UIProcess/WebPageProxy.messages.in: Update StartDrag message parameters. 38 * UIProcess/gtk/DragAndDropHandler.cpp: 39 (WebKit::DragAndDropHandler::DragAndDropHandler): Remove unneeded initialization. 40 (WebKit::DragAndDropHandler::startDrag): Take ownership of the given DataObjectGtk. 41 * UIProcess/gtk/DragAndDropHandler.h: 42 * UIProcess/gtk/WebPasteboardProxyGtk.cpp: 43 (WebKit::WebPasteboardProxy::writeToClipboard): 44 (WebKit::WebPasteboardProxy::readFromClipboard): 45 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 46 (WebKit::WebPlatformStrategies::writeToClipboard): 47 (WebKit::WebPlatformStrategies::readFromClipboard): 48 * WebProcess/WebCoreSupport/WebPlatformStrategies.h: 49 * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp: 50 (WebKit::convertCairoSurfaceToShareableBitmap): 51 (WebKit::WebDragClient::startDrag): Do not create a DragData and pass the DataObjectGtk directly to the 52 message. Also notify the WebPage that drag is about to start. 53 * WebProcess/WebPage/WebPage.cpp: 54 (WebKit::WebPage::performDragControllerAction): Remove explicit DataObjectGtk derefs and simply create a 55 DragData using the DataObjectGtk pointer as platform data. 56 * WebProcess/WebPage/WebPage.h: 57 * WebProcess/WebPage/WebPage.messages.in: Update PerformDragControllerAction message parameters. 58 1 59 2016-09-20 Hunseop Jeong <hs85.jeong@samsung.com> 2 60 -
trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp
r205909 r206197 31 31 #include "WebCoreArgumentCoders.h" 32 32 #include <WebCore/DataObjectGtk.h> 33 #include <WebCore/DragData.h>34 33 #include <WebCore/GraphicsContext.h> 35 #include <WebCore/ GtkVersioning.h>36 #include < WebCore/PlatformContextCairo.h>34 #include <WebCore/Image.h> 35 #include <gtk/gtk.h> 37 36 #include <wtf/glib/GUniquePtr.h> 38 37 … … 42 41 namespace IPC { 43 42 44 static void encodeImage(Encoder& encoder, const GdkPixbuf* pixbuf) 45 { 46 IntSize imageSize(gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf)); 47 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(imageSize, ShareableBitmap::SupportsAlpha); 48 auto graphicsContext = bitmap->createGraphicsContext(); 49 50 cairo_t* cr = graphicsContext->platformContext()->cr(); 51 gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); 52 cairo_paint(cr); 43 static void encodeImage(Encoder& encoder, Image& image) 44 { 45 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha); 46 bitmap->createGraphicsContext()->drawImage(image, IntPoint()); 53 47 54 48 ShareableBitmap::Handle handle; … … 58 52 } 59 53 60 static bool decodeImage(Decoder& decoder, GRefPtr<GdkPixbuf>& pixbuf)54 static bool decodeImage(Decoder& decoder, RefPtr<Image>& image) 61 55 { 62 56 ShareableBitmap::Handle handle; … … 67 61 if (!bitmap) 68 62 return false; 69 70 RefPtr<Image> image = bitmap->createImage(); 63 image = bitmap->createImage(); 71 64 if (!image) 72 65 return false; 73 74 RefPtr<cairo_surface_t> surface = image->nativeImageForCurrentFrame();75 if (!surface)76 return false;77 78 pixbuf = adoptGRef(gdk_pixbuf_get_from_surface(surface.get(), 0, 0, cairo_image_surface_get_width(surface.get()), cairo_image_surface_get_height(surface.get())));79 if (!pixbuf)80 return false;81 82 66 return true; 83 67 } 84 68 85 void encode(Encoder& encoder, const DataObjectGtk*dataObject)86 { 87 bool hasText = dataObject ->hasText();69 void ArgumentCoder<DataObjectGtk>::encode(Encoder& encoder, const DataObjectGtk& dataObject) 70 { 71 bool hasText = dataObject.hasText(); 88 72 encoder << hasText; 89 73 if (hasText) 90 encoder << dataObject ->text();91 92 bool hasMarkup = dataObject ->hasMarkup();74 encoder << dataObject.text(); 75 76 bool hasMarkup = dataObject.hasMarkup(); 93 77 encoder << hasMarkup; 94 78 if (hasMarkup) 95 encoder << dataObject ->markup();96 97 bool hasURL = dataObject ->hasURL();79 encoder << dataObject.markup(); 80 81 bool hasURL = dataObject.hasURL(); 98 82 encoder << hasURL; 99 83 if (hasURL) 100 encoder << dataObject ->url().string();101 102 bool hasURIList = dataObject ->hasURIList();84 encoder << dataObject.url().string(); 85 86 bool hasURIList = dataObject.hasURIList(); 103 87 encoder << hasURIList; 104 88 if (hasURIList) 105 encoder << dataObject ->uriList();106 107 bool hasImage = dataObject ->hasImage();89 encoder << dataObject.uriList(); 90 91 bool hasImage = dataObject.hasImage(); 108 92 encoder << hasImage; 109 93 if (hasImage) 110 encodeImage(encoder, dataObject->image());111 112 bool hasUnknownTypeData = dataObject ->hasUnknownTypeData();94 encodeImage(encoder, *dataObject.image()); 95 96 bool hasUnknownTypeData = dataObject.hasUnknownTypeData(); 113 97 encoder << hasUnknownTypeData; 114 98 if (hasUnknownTypeData) 115 encoder << dataObject ->unknownTypes();116 117 bool canSmartReplace = dataObject ->canSmartReplace();99 encoder << dataObject.unknownTypes(); 100 101 bool canSmartReplace = dataObject.canSmartReplace(); 118 102 encoder << canSmartReplace; 119 103 } 120 104 121 bool decode(Decoder& decoder, RefPtr<DataObjectGtk>& dataObject)122 { 123 RefPtr<DataObjectGtk> data = DataObjectGtk::create();105 bool ArgumentCoder<DataObjectGtk>::decode(Decoder& decoder, DataObjectGtk& dataObject) 106 { 107 dataObject.clearAll(); 124 108 125 109 bool hasText; … … 130 114 if (!decoder.decode(text)) 131 115 return false; 132 data ->setText(text);116 dataObject.setText(text); 133 117 } 134 118 … … 140 124 if (!decoder.decode(markup)) 141 125 return false; 142 data ->setMarkup(markup);126 dataObject.setMarkup(markup); 143 127 } 144 128 … … 150 134 if (!decoder.decode(url)) 151 135 return false; 152 data ->setURL(URL(URL(), url), String());136 dataObject.setURL(URL(URL(), url), String()); 153 137 } 154 138 … … 160 144 if (!decoder.decode(uriList)) 161 145 return false; 162 data ->setURIList(uriList);146 dataObject.setURIList(uriList); 163 147 } 164 148 … … 167 151 return false; 168 152 if (hasImage) { 169 GRefPtr<GdkPixbuf> image;153 RefPtr<Image> image; 170 154 if (!decodeImage(decoder, image)) 171 155 return false; 172 data ->setImage(image.get());156 dataObject.setImage(image.get()); 173 157 } 174 158 … … 183 167 auto end = unknownTypes.end(); 184 168 for (auto it = unknownTypes.begin(); it != end; ++it) 185 data ->setUnknownTypeData(it->key, it->value);169 dataObject.setUnknownTypeData(it->key, it->value); 186 170 } 187 171 … … 189 173 if (!decoder.decode(canSmartReplace)) 190 174 return false; 191 data->setCanSmartReplace(canSmartReplace); 192 193 dataObject = data; 175 dataObject.setCanSmartReplace(canSmartReplace); 194 176 195 177 return true; 196 178 } 197 198 #if ENABLE(DRAG_SUPPORT)199 void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)200 {201 encoder << dragData.clientPosition();202 encoder << dragData.globalPosition();203 encoder << static_cast<uint64_t>(dragData.draggingSourceOperationMask());204 encoder << static_cast<uint64_t>(dragData.flags());205 206 DataObjectGtk* platformData = dragData.platformData();207 encoder << static_cast<bool>(platformData);208 if (platformData)209 IPC::encode(encoder, platformData);210 }211 212 bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)213 {214 IntPoint clientPosition;215 if (!decoder.decode(clientPosition))216 return false;217 218 IntPoint globalPosition;219 if (!decoder.decode(globalPosition))220 return false;221 222 uint64_t sourceOperationMask;223 if (!decoder.decode(sourceOperationMask))224 return false;225 226 uint64_t flags;227 if (!decoder.decode(flags))228 return false;229 230 bool hasPlatformData;231 if (!decoder.decode(hasPlatformData))232 return false;233 234 RefPtr<DataObjectGtk> platformData;235 if (hasPlatformData) {236 if (!IPC::decode(decoder, platformData))237 return false;238 }239 240 dragData = DragData(platformData.leakRef(), clientPosition, globalPosition, static_cast<DragOperation>(sourceOperationMask),241 static_cast<DragApplicationFlags>(flags));242 243 return true;244 }245 #endif // ENABLE(DRAG_SUPPORT)246 179 247 180 static void encodeGKeyFile(Encoder& encoder, GKeyFile* keyFile) -
trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h
r205909 r206197 35 35 namespace WebCore { 36 36 class DataObjectGtk; 37 class DragData;38 37 } 39 38 40 39 namespace IPC { 41 42 #if ENABLE(DRAG_SUPPORT)43 template<> struct ArgumentCoder<WebCore::DragData> {44 static void encode(Encoder&, const WebCore::DragData&);45 static bool decode(Decoder&, WebCore::DragData&);46 };47 #endif48 40 49 41 void encode(Encoder&, GtkPrintSettings*); … … 53 45 bool decode(Decoder&, GRefPtr<GtkPageSetup>&); 54 46 55 void encode(Encoder&, const WebCore::DataObjectGtk*); 56 bool decode(Decoder&, RefPtr<WebCore::DataObjectGtk>&); 47 template<> struct ArgumentCoder<WebCore::DataObjectGtk> { 48 static void encode(Encoder&, const WebCore::DataObjectGtk&); 49 static bool decode(Decoder&, WebCore::DataObjectGtk&); 50 }; 57 51 58 52 } // namespace IPC -
trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp
r205909 r206197 28 28 namespace WebKit { 29 29 30 PasteboardContent::PasteboardContent( const RefPtr<WebCore::DataObjectGtk>& data)31 : dataObject( data)30 PasteboardContent::PasteboardContent() 31 : dataObject(WebCore::DataObjectGtk::create()) 32 32 { 33 ASSERT(dataObject); 33 } 34 35 PasteboardContent::PasteboardContent(const WebCore::DataObjectGtk& data) 36 : dataObject(const_cast<WebCore::DataObjectGtk&>(data)) 37 { 38 } 39 40 PasteboardContent::PasteboardContent(Ref<WebCore::DataObjectGtk>&& data) 41 : dataObject(WTFMove(data)) 42 { 34 43 } 35 44 36 45 void PasteboardContent::encode(IPC::Encoder& encoder) const 37 46 { 38 IPC::encode(encoder, dataObject.get());47 encoder << dataObject.get(); 39 48 } 40 49 41 50 bool PasteboardContent::decode(IPC::Decoder& decoder, PasteboardContent& pasteboardContent) 42 51 { 43 return IPC::decode(decoder, pasteboardContent.dataObject);52 return decoder.decode(pasteboardContent.dataObject.get()); 44 53 } 45 54 -
trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h
r205909 r206197 30 30 31 31 struct PasteboardContent { 32 PasteboardContent() = default; 33 explicit PasteboardContent(const RefPtr<WebCore::DataObjectGtk>&); 32 PasteboardContent(); 33 explicit PasteboardContent(const WebCore::DataObjectGtk&); 34 explicit PasteboardContent(Ref<WebCore::DataObjectGtk>&&); 34 35 35 Ref Ptr<WebCore::DataObjectGtk> dataObject;36 Ref<WebCore::DataObjectGtk> dataObject; 36 37 37 38 void encode(IPC::Encoder&) const; -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
r204013 r206197 255 255 256 256 #if ENABLE(DRAG_SUPPORT) 257 void PageClientImpl::startDrag( const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap>dragImage)257 void PageClientImpl::startDrag(Ref<DataObjectGtk>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage) 258 258 { 259 259 WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget); 260 webkitWebViewBaseDragAndDropHandler(webView).startDrag( dragData, dragImage);260 webkitWebViewBaseDragAndDropHandler(webView).startDrag(WTFMove(selection), dragOperation, WTFMove(dragImage)); 261 261 262 262 // A drag starting should prevent a double-click from happening. This might -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
r204013 r206197 87 87 void selectionDidChange() override; 88 88 #if ENABLE(DRAG_SUPPORT) 89 void startDrag( const WebCore::DragData&, PassRefPtr<ShareableBitmap>dragImage) override;89 void startDrag(Ref<WebCore::DataObjectGtk>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) override; 90 90 #endif 91 91 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r205412 r206197 158 158 159 159 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT) 160 virtual void startDrag( const WebCore::DragData&, PassRefPtr<ShareableBitmap>dragImage) = 0;160 virtual void startDrag(Ref<WebCore::DataObjectGtk>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage) = 0; 161 161 #endif 162 162 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r206040 r206197 156 156 #endif 157 157 158 #if PLATFORM(GTK) 159 #include "PasteboardContent.h" 160 #endif 161 158 162 #if USE(CAIRO) 159 163 #include <WebCore/CairoUtilities.h> … … 1769 1773 if (!url.isEmpty()) 1770 1774 m_process->assumeReadAccessToBaseURL(url); 1771 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID); 1775 1776 ASSERT(dragData.platformData()); 1777 PasteboardContent selection(*dragData.platformData()); 1778 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), selection, dragData.flags()), m_pageID); 1772 1779 #else 1773 1780 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID); … … 1785 1792 1786 1793 #if PLATFORM(GTK) 1787 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle) 1788 { 1789 RefPtr<ShareableBitmap> dragImage = 0; 1790 if (!dragImageHandle.isNull()) { 1791 dragImage = ShareableBitmap::create(dragImageHandle); 1792 if (!dragImage) 1793 return; 1794 } 1795 1796 m_pageClient.startDrag(dragData, dragImage.release()); 1794 void WebPageProxy::startDrag(PasteboardContent&& selection, uint64_t dragOperation, const ShareableBitmap::Handle& dragImageHandle) 1795 { 1796 RefPtr<ShareableBitmap> dragImage = !dragImageHandle.isNull() ? ShareableBitmap::create(dragImageHandle) : nullptr; 1797 m_pageClient.startDrag(WTFMove(selection.dataObject), static_cast<WebCore::DragOperation>(dragOperation), WTFMove(dragImage)); 1798 1799 m_process->send(Messages::WebPage::DidStartDrag(), m_pageID); 1797 1800 } 1798 1801 #endif -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r206033 r206197 810 810 #endif 811 811 #if PLATFORM(GTK) 812 void startDrag( const WebCore::DragData&, const ShareableBitmap::Handle& dragImage);812 void startDrag(PasteboardContent&&, uint64_t dragOperation, const ShareableBitmap::Handle& dragImage); 813 813 #endif 814 814 #endif -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r206006 r206197 309 309 #endif 310 310 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT) 311 StartDrag( WebCore::DragData dragData, WebKit::ShareableBitmap::Handle dragImage)311 StartDrag(struct WebKit::PasteboardContent selection, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage) 312 312 #endif 313 313 -
trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp
r205860 r206197 45 45 DragAndDropHandler::DragAndDropHandler(WebPageProxy& page) 46 46 : m_page(page) 47 #if GTK_CHECK_VERSION(3, 16, 0)48 , m_dragContext(nullptr)49 #endif50 47 { 51 48 } … … 112 109 } 113 110 114 void DragAndDropHandler::startDrag( const DragData& dragData, PassRefPtr<ShareableBitmap>dragImage)111 void DragAndDropHandler::startDrag(Ref<DataObjectGtk>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage) 115 112 { 116 113 #if GTK_CHECK_VERSION(3, 16, 0) 117 m_draggingDataObject = adoptRef(dragData.platformData());114 m_draggingDataObject = WTFMove(selection); 118 115 GRefPtr<GtkTargetList> targetList = PasteboardHelper::singleton().targetListForDataObject(*m_draggingDataObject); 119 116 #else 120 RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());117 RefPtr<DataObjectGtk> dataObject = WTFMove(selection); 121 118 GRefPtr<GtkTargetList> targetList = PasteboardHelper::singleton().targetListForDataObject(*dataObject); 122 119 #endif 123 120 124 121 GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event()); 125 GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(drag Data.draggingSourceOperationMask()),122 GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragOperation), 126 123 GDK_BUTTON_PRIMARY, currentEvent.get()); 127 124 … … 136 133 // We don't have gtk_drag_cancel() in GTK+ < 3.16, so we use the old code. 137 134 // See https://bugs.webkit.org/show_bug.cgi?id=138468 138 m_draggingDataObjects.set(context, dataObject.get());135 m_draggingDataObjects.set(context, WTFMove(dataObject)); 139 136 #endif 140 137 -
trunk/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.h
r195811 r206197 24 24 */ 25 25 26 #ifndef DragAndDropHandler_h 27 #define DragAndDropHandler_h 26 #pragma once 28 27 29 28 #if ENABLE(DRAG_SUPPORT) 30 29 31 30 #include <WebCore/DataObjectGtk.h> 31 #include <WebCore/DragActions.h> 32 32 #include <WebCore/IntPoint.h> 33 33 #include <gtk/gtk.h> 34 34 #include <wtf/HashMap.h> 35 35 #include <wtf/Noncopyable.h> 36 #include <wtf/glib/GRefPtr.h> 36 37 37 38 typedef struct _GdkDragContext GdkDragContext; … … 52 53 DragAndDropHandler(WebPageProxy&); 53 54 54 void startDrag( const WebCore::DragData&, PassRefPtr<ShareableBitmap>dragImage);55 void startDrag(Ref<WebCore::DataObjectGtk>&&, WebCore::DragOperation, RefPtr<ShareableBitmap>&& dragImage); 55 56 void fillDragData(GdkDragContext*, GtkSelectionData*, unsigned info); 56 57 void finishDrag(GdkDragContext*); … … 91 92 92 93 #endif // ENABLE(DRAG_SUPPORT) 93 94 #endif // DragAndDropHandler_h -
trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp
r205909 r206197 42 42 { 43 43 TemporaryChange<WebFrameProxy*> frameWritingToClipboard(m_frameWritingToClipboard, m_primarySelectionOwner); 44 PlatformPasteboard(pasteboardName).writeToClipboard(pasteboardContent.dataObject , [this] {44 PlatformPasteboard(pasteboardName).writeToClipboard(pasteboardContent.dataObject.get(), [this] { 45 45 if (m_frameWritingToClipboard == m_primarySelectionOwner) 46 46 return; … … 51 51 void WebPasteboardProxy::readFromClipboard(const String& pasteboardName, PasteboardContent& pasteboardContent) 52 52 { 53 pasteboardContent = PasteboardContent(PlatformPasteboard(pasteboardName).readFromClipboard() .get());53 pasteboardContent = PasteboardContent(PlatformPasteboard(pasteboardName).readFromClipboard()); 54 54 } 55 55 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r205909 r206197 347 347 // PasteboardStrategy 348 348 349 void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>& dataObject)350 { 351 PasteboardContent pasteboardContent = PasteboardContent(dataObject.get());349 void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, const DataObjectGtk& dataObject) 350 { 351 PasteboardContent pasteboardContent(dataObject); 352 352 WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, pasteboardContent), 0); 353 353 } 354 354 355 Ref Ptr<WebCore::DataObjectGtk> WebPlatformStrategies::readFromClipboard(const String& pasteboardName)355 Ref<DataObjectGtk> WebPlatformStrategies::readFromClipboard(const String& pasteboardName) 356 356 { 357 357 PasteboardContent pasteboardContent; 358 358 WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadFromClipboard(pasteboardName), Messages::WebPasteboardProxy::ReadFromClipboard::Reply(pasteboardContent), 0); 359 return pasteboardContent.dataObject;359 return WTFMove(pasteboardContent.dataObject); 360 360 } 361 361 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
r205909 r206197 88 88 #endif 89 89 #if PLATFORM(GTK) 90 void writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>&) override;91 Ref Ptr<WebCore::DataObjectGtk> readFromClipboard(const String& pasteboardName) override;90 void writeToClipboard(const String& pasteboardName, const WebCore::DataObjectGtk&) override; 91 Ref<WebCore::DataObjectGtk> readFromClipboard(const String& pasteboardName) override; 92 92 #endif 93 93 }; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
r205860 r206197 30 30 31 31 #include "ArgumentCodersGtk.h" 32 #include "PasteboardContent.h" 32 33 #include "ShareableBitmap.h" 33 34 #include "WebPage.h" … … 44 45 namespace WebKit { 45 46 46 static PassRefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_surface_t* surface)47 static RefPtr<ShareableBitmap> convertCairoSurfaceToShareableBitmap(cairo_surface_t* surface) 47 48 { 48 49 if (!surface) 49 return 0;50 return nullptr; 50 51 51 52 IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface)); … … 54 55 55 56 graphicsContext->platformContext()->drawSurfaceToContext(surface, IntRect(IntPoint(), imageSize), IntRect(IntPoint(), imageSize), *graphicsContext); 56 return bitmap .release();57 return bitmap; 57 58 } 58 59 … … 66 67 return; 67 68 68 const auto& dataObject = dataTransfer.pasteboard().dataObject(); 69 DragData dragData(const_cast<DataObjectGtk*>(&dataObject), clientPosition, globalPosition, dataTransfer.sourceOperation()); 70 m_page->send(Messages::WebPageProxy::StartDrag(dragData, handle)); 69 m_page->willStartDrag(); 70 71 PasteboardContent selection(dataTransfer.pasteboard().dataObject()); 72 m_page->send(Messages::WebPageProxy::StartDrag(selection, dataTransfer.sourceOperation(), handle)); 71 73 } 72 74 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r206119 r206197 218 218 219 219 #if PLATFORM(GTK) 220 #include "PasteboardContent.h" 221 #include "WebPrintOperationGtk.h" 222 #include <WebCore/DataObjectGtk.h> 220 223 #include <gtk/gtk.h> 221 #include "DataObjectGtk.h"222 #include "WebPrintOperationGtk.h"223 224 #endif 224 225 … … 3397 3398 3398 3399 #if PLATFORM(GTK) 3399 void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dragData)3400 void WebPage::performDragControllerAction(uint64_t action, const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t draggingSourceOperationMask, PasteboardContent&& selection, uint32_t flags) 3400 3401 { 3401 3402 if (!m_page) { 3402 3403 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0)); 3403 DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData()); 3404 data->deref(); 3405 return; 3406 } 3407 3404 return; 3405 } 3406 3407 DragData dragData(selection.dataObject.ptr(), clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags)); 3408 3408 switch (action) { 3409 3409 case DragControllerActionEntered: { … … 3429 3429 ASSERT_NOT_REACHED(); 3430 3430 } 3431 // DragData does not delete its platformData so we need to do that here. 3432 DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData()); 3433 data->deref(); 3434 } 3435 3431 } 3436 3432 #else 3437 3433 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsHandleArray) -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r206033 r206197 205 205 #endif 206 206 207 #if PLATFORM(GTK) 208 struct PasteboardContent; 209 #endif 210 207 211 #if ENABLE(TOUCH_EVENTS) 208 212 class WebTouchEvent; … … 730 734 #if ENABLE(DRAG_SUPPORT) 731 735 #if PLATFORM(GTK) 732 void performDragControllerAction(uint64_t action, WebCore::DragData);736 void performDragControllerAction(uint64_t action, const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t draggingSourceOperationMask, PasteboardContent&&, uint32_t flags); 733 737 #else 734 738 void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&, const SandboxExtension::HandleArray&); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r206033 r206197 237 237 # Drag and drop. 238 238 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT) 239 PerformDragControllerAction(uint64_t action, WebCore:: DragData dragData)239 PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, struct WebKit::PasteboardContent selection, uint32_t flags) 240 240 #endif 241 241 #if !PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
Note: See TracChangeset
for help on using the changeset viewer.