Changeset 218837 in webkit
- Timestamp:
- Jun 27, 2017 12:11:34 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r218835 r218837 1 2017-06-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag start codepaths to plumb a DragItem to client layers 4 https://bugs.webkit.org/show_bug.cgi?id=173832 5 Work towards <rdar://problem/32236827> 6 7 Reviewed by Ryosuke Niwa and Tim Horton. 8 9 Refactor drag start logic in WebCore to set up a DragItem and propagate it to WebDragClient. No change in behavior. 10 11 * loader/EmptyClients.cpp: 12 * page/DragClient.h: 13 * page/DragController.cpp: 14 (WebCore::DragController::startDrag): 15 (WebCore::DragController::doImageDrag): 16 (WebCore::DragController::doSystemDrag): 17 18 Refactor to pass along a DragItem. Also, remove unused drag image anchor computation. 19 20 * page/DragController.h: 21 * platform/DragImage.h: 22 * platform/DragItem.h: 23 24 Add additional information needed to begin a drag on iOS. 25 26 (WebCore::DragItem::encode): 27 (WebCore::DragItem::decode): 28 29 Add IPC serialization/deserialization support for DragItem. 30 31 * platform/PasteboardWriterData.cpp: 32 (WebCore::PasteboardWriterData::isEmpty): 33 * platform/PasteboardWriterData.h: 34 1 35 2017-06-27 Frederic Wang <fwang@igalia.com> 2 36 -
trunk/Source/WebCore/loader/EmptyClients.cpp
r218501 r218837 132 132 void willPerformDragSourceAction(DragSourceAction, const IntPoint&, DataTransfer&) final { } 133 133 DragSourceAction dragSourceActionMaskForPoint(const IntPoint&) final { return DragSourceActionNone; } 134 void startDrag(DragI mage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, DragSourceAction) final { }134 void startDrag(DragItem, DataTransfer&, Frame&) final { } 135 135 void dragControllerDestroyed() final { } 136 136 }; -
trunk/Source/WebCore/page/DragClient.h
r214403 r218837 50 50 virtual DragSourceAction dragSourceActionMaskForPoint(const IntPoint& rootViewPoint) = 0; 51 51 52 virtual void startDrag(DragI mage, const IntPoint& dragImageOrigin, const IntPoint& eventPos, const FloatPoint& dragImageAnchor, DataTransfer&, Frame&, DragSourceAction) = 0;52 virtual void startDrag(DragItem, DataTransfer&, Frame&) = 0; 53 53 virtual void dragEnded() { } 54 54 -
trunk/Source/WebCore/page/DragController.cpp
r218611 r218837 44 44 #include "Editor.h" 45 45 #include "EditorClient.h" 46 #include "ElementAncestorIterator.h" 46 47 #include "EventHandler.h" 47 48 #include "FloatRect.h" … … 53 54 #include "HTMLImageElement.h" 54 55 #include "HTMLInputElement.h" 56 #include "HTMLParserIdioms.h" 55 57 #include "HTMLPlugInElement.h" 56 58 #include "HitTestRequest.h" … … 964 966 965 967 if (mustUseLegacyDragClient) { 966 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, dragImageBounds, dataTransfer, src, DragSourceActionSelection);968 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state); 967 969 return true; 968 970 } … … 997 999 998 1000 if (!dragImage) 999 doImageDrag(element, dragOrigin, hitTestResult.imageRect(), dataTransfer, src, m_dragOffset);1001 doImageDrag(element, dragOrigin, hitTestResult.imageRect(), src, m_dragOffset, state); 1000 1002 else { 1001 1003 // DHTML defined drag image 1002 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionImage);1004 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state); 1003 1005 } 1004 1006 … … 1052 1054 1053 1055 if (mustUseLegacyDragClient) { 1054 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionLink);1056 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state); 1055 1057 return true; 1056 1058 } … … 1103 1105 m_dragOffset = IntPoint(dragOrigin.x() - dragLoc.x(), dragOrigin.y() - dragLoc.y()); 1104 1106 } 1105 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionAttachment);1107 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state); 1106 1108 src.selection().setSelection(previousSelection); 1107 1109 src.editor().setIgnoreSelectionChanges(false); … … 1113 1115 ASSERT(m_dragSourceAction & DragSourceActionDHTML); 1114 1116 m_client.willPerformDragSourceAction(DragSourceActionDHTML, dragOrigin, dataTransfer); 1115 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, { }, dataTransfer, src, DragSourceActionDHTML);1117 doSystemDrag(WTFMove(dragImage), dragLoc, dragOrigin, src, state); 1116 1118 return true; 1117 1119 } … … 1120 1122 } 1121 1123 1122 void DragController::doImageDrag(Element& element, const IntPoint& dragOrigin, const IntRect& layoutRect, DataTransfer& dataTransfer, Frame& frame, IntPoint& dragImageOffset)1124 void DragController::doImageDrag(Element& element, const IntPoint& dragOrigin, const IntRect& layoutRect, Frame& frame, IntPoint& dragImageOffset, const DragState& state) 1123 1125 { 1124 1126 IntPoint mouseDownPoint = dragOrigin; … … 1161 1163 1162 1164 dragImageOffset = mouseDownPoint + scaledOrigin; 1163 doSystemDrag(WTFMove(dragImage), dragImageOffset, dragOrigin, element.boundsInRootViewSpace(), dataTransfer, frame, DragSourceActionImage);1165 doSystemDrag(WTFMove(dragImage), dragImageOffset, dragOrigin, frame, state); 1164 1166 } 1165 1167 … … 1188 1190 } 1189 1191 1190 void DragController::doSystemDrag(DragImage image, const IntPoint& dragLoc, const IntPoint& eventPos, const IntRect& dragImageBounds, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction) 1191 { 1192 FloatPoint dragImageAnchor = { 0.5, 0.5 }; 1193 if (dragSourceAction == DragSourceActionLink) 1194 dragImageAnchor.setY(1); 1195 else if (!dragImageBounds.isEmpty()) { 1196 dragImageAnchor.setX((eventPos.x() - dragImageBounds.x()) / (float)dragImageBounds.width()); 1197 dragImageAnchor.setY((eventPos.y() - dragImageBounds.y()) / (float)dragImageBounds.height()); 1198 } 1199 1192 void DragController::doSystemDrag(DragImage image, const IntPoint& dragLoc, const IntPoint& eventPos, Frame& frame, const DragState& state) 1193 { 1200 1194 m_didInitiateDrag = true; 1201 1195 m_dragInitiator = frame.document(); … … 1203 1197 Ref<MainFrame> frameProtector(m_page.mainFrame()); 1204 1198 RefPtr<FrameView> viewProtector = frameProtector->view(); 1205 m_client.startDrag(WTFMove(image), viewProtector->rootViewToContents(frame.view()->contentsToRootView(dragLoc)), viewProtector->rootViewToContents(frame.view()->contentsToRootView(eventPos)), dragImageAnchor, dataTransfer, frameProtector.get(), dragSourceAction); 1199 1200 DragItem item; 1201 item.image = WTFMove(image); 1202 item.sourceAction = state.type; 1203 item.eventPositionInContentCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(eventPos)); 1204 item.dragLocationInContentCoordinates = viewProtector->rootViewToContents(frame.view()->contentsToRootView(dragLoc)); 1205 item.eventPositionInWindowCoordinates = frame.view()->contentsToWindow(item.eventPositionInContentCoordinates); 1206 item.dragLocationInWindowCoordinates = frame.view()->contentsToWindow(item.dragLocationInContentCoordinates); 1207 if (auto element = state.source) { 1208 item.elementBounds = element->boundsInRootViewSpace(); 1209 RefPtr<Element> link; 1210 if (element->isLink()) 1211 link = element; 1212 else { 1213 for (auto& currentElement : elementLineage(element.get())) { 1214 if (currentElement.isLink()) { 1215 link = ¤tElement; 1216 break; 1217 } 1218 } 1219 } 1220 if (link) { 1221 auto titleAttribute = link->attributeWithoutSynchronization(HTMLNames::titleAttr); 1222 item.title = titleAttribute.isEmpty() ? link->innerText() : titleAttribute.string(); 1223 item.url = frame.document()->completeURL(stripLeadingAndTrailingHTMLSpaces(link->getAttribute(HTMLNames::hrefAttr))); 1224 } 1225 } 1226 m_client.startDrag(WTFMove(item), *state.dataTransfer, frameProtector.get()); 1206 1227 // DragClient::startDrag can cause our Page to dispear, deallocating |this|. 1207 1228 if (!frameProtector->page()) -
trunk/Source/WebCore/page/DragController.h
r218343 r218837 116 116 bool shouldUseCachedImageForDragImage(const Image&) const; 117 117 118 void doImageDrag(Element&, const IntPoint&, const IntRect&, DataTransfer&, Frame&, IntPoint&);119 void doSystemDrag(DragImage, const IntPoint&, const IntPoint&, const IntRect& dragImageBounds, DataTransfer&, Frame&, DragSourceAction);118 void doImageDrag(Element&, const IntPoint&, const IntRect&, Frame&, IntPoint&, const DragState&); 119 void doSystemDrag(DragImage, const IntPoint&, const IntPoint&, Frame&, const DragState&); 120 120 121 121 void beginDrag(DragItem, Frame&, const IntPoint& mouseDownPoint, const IntPoint& mouseDraggedPoint, DataTransfer&, DragSourceAction); -
trunk/Source/WebCore/platform/DragImage.h
r217727 r218837 98 98 class DragImage final { 99 99 public: 100 DragImage();100 WEBCORE_EXPORT DragImage(); 101 101 explicit DragImage(DragImageRef); 102 102 DragImage(DragImage&&); 103 ~DragImage();103 WEBCORE_EXPORT ~DragImage(); 104 104 105 105 DragImage& operator=(DragImage&&); -
trunk/Source/WebCore/platform/DragItem.h
r212663 r218837 28 28 #include "DragImage.h" 29 29 #include "FloatPoint.h" 30 #include "IntPoint.h" 31 #include "IntRect.h" 30 32 #include "PasteboardWriterData.h" 31 33 … … 38 40 FloatPoint imageAnchorPoint; 39 41 42 DragSourceAction sourceAction { DragSourceActionNone }; 43 IntPoint eventPositionInContentCoordinates; 44 IntPoint dragLocationInContentCoordinates; 45 IntPoint eventPositionInWindowCoordinates; 46 IntPoint dragLocationInWindowCoordinates; 47 String title; 48 URL url; 49 IntRect elementBounds; 50 40 51 PasteboardWriterData data; 52 53 template<class Encoder> void encode(Encoder&) const; 54 template<class Decoder> static bool decode(Decoder&, DragItem&); 41 55 }; 42 56 57 template<class Encoder> 58 void DragItem::encode(Encoder& encoder) const 59 { 60 // FIXME(173815): We should encode and decode PasteboardWriterData and platform drag image data 61 // here too, as part of moving off of the legacy dragging codepath. 62 encoder.encodeEnum(sourceAction); 63 encoder << imageAnchorPoint << eventPositionInContentCoordinates << dragLocationInContentCoordinates << eventPositionInWindowCoordinates << dragLocationInWindowCoordinates << title << url << elementBounds; 64 bool hasIndicatorData = image.hasIndicatorData(); 65 encoder << hasIndicatorData; 66 if (hasIndicatorData) 67 encoder << image.indicatorData().value(); 43 68 } 69 70 template<class Decoder> 71 bool DragItem::decode(Decoder& decoder, DragItem& result) 72 { 73 if (!decoder.decodeEnum(result.sourceAction)) 74 return false; 75 if (!decoder.decode(result.imageAnchorPoint)) 76 return false; 77 if (!decoder.decode(result.eventPositionInContentCoordinates)) 78 return false; 79 if (!decoder.decode(result.dragLocationInContentCoordinates)) 80 return false; 81 if (!decoder.decode(result.eventPositionInWindowCoordinates)) 82 return false; 83 if (!decoder.decode(result.dragLocationInWindowCoordinates)) 84 return false; 85 if (!decoder.decode(result.title)) 86 return false; 87 if (!decoder.decode(result.url)) 88 return false; 89 if (!decoder.decode(result.elementBounds)) 90 return false; 91 bool hasIndicatorData; 92 if (!decoder.decode(hasIndicatorData)) 93 return false; 94 if (hasIndicatorData) { 95 TextIndicatorData indicatorData; 96 if (!decoder.decode(indicatorData)) 97 return false; 98 result.image.setIndicatorData(indicatorData); 99 } 100 return true; 101 } 102 103 } -
trunk/Source/WebCore/platform/PasteboardWriterData.cpp
r213597 r218837 49 49 bool PasteboardWriterData::isEmpty() const 50 50 { 51 if (m_plainText) 52 return false; 53 54 if (m_url) 55 return false; 56 57 return true; 51 return !m_plainText && !m_url && !m_webContent; 58 52 } 59 53 -
trunk/Source/WebCore/platform/PasteboardWriterData.h
r214865 r218837 36 36 class PasteboardWriterData final { 37 37 public: 38 PasteboardWriterData();39 ~PasteboardWriterData();38 WEBCORE_EXPORT PasteboardWriterData(); 39 WEBCORE_EXPORT ~PasteboardWriterData(); 40 40 41 41 WEBCORE_EXPORT bool isEmpty() const; -
trunk/Source/WebKit/mac/ChangeLog
r218794 r218837 1 2017-06-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag start codepaths to plumb a DragItem to client layers 4 https://bugs.webkit.org/show_bug.cgi?id=173832 5 Work towards <rdar://problem/32236827> 6 7 Reviewed by Ryosuke Niwa and Tim Horton. 8 9 Refactor code used to start a drag in WebKit1 to plumb a single DragItem from DragController to the client layer 10 in WebDragClient that contains all the information needed to begin a drag. Also renames _setDataInteractionData: 11 to _startDrag: to match logic used to start a drag on other platforms. 12 13 No behavior change -- the same information should be propagated to AppKit and UIKit when beginning a drag, only 14 through the DragItem struct. 15 16 * WebCoreSupport/WebDragClient.h: 17 * WebCoreSupport/WebDragClient.mm: 18 (WebDragClient::startDrag): 19 (WebDragClient::dragSourceActionMaskForPoint): 20 (WebDragClient::willPerformDragSourceAction): 21 (WebDragClient::beginDrag): 22 * WebView/WebView.mm: 23 (-[WebView _startDrag:]): 24 (-[WebView _setDataInteractionData:textIndicator:atClientPosition:anchorPoint:action:]): Deleted. 25 * WebView/WebViewInternal.h: 26 1 27 2017-06-25 Konstantin Tokarev <annulen@yandex.ru> 2 28 -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.h
r214403 r218837 40 40 void dragControllerDestroyed() override; 41 41 WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override; 42 void startDrag(WebCore::DragI mage, const WebCore::IntPoint& dragPos, const WebCore::IntPoint& eventPos, const WebCore::FloatPoint&, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction) override;42 void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&) override; 43 43 44 44 void beginDrag(WebCore::DragItem, WebCore::Frame&, const WebCore::IntPoint& mouseDownPosition, const WebCore::IntPoint& mouseDraggedPosition, WebCore::DataTransfer&, WebCore::DragSourceAction) override; -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
r218433 r218837 51 51 #import <WebCore/EditorClient.h> 52 52 #import <WebCore/EventHandler.h> 53 #import <WebCore/FloatPoint.h> 53 54 #import <WebCore/FrameView.h> 54 55 #import <WebCore/Image.h> … … 101 102 } 102 103 103 void WebDragClient::startDrag(DragImage dragImage, const IntPoint& at, const IntPoint& eventPos, const FloatPoint&, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction) 104 { 104 void WebDragClient::startDrag(DragItem dragItem, DataTransfer& dataTransfer, Frame& frame) 105 { 106 auto& dragImage = dragItem.image; 107 auto dragLocationInContentCoordinates = dragItem.dragLocationInContentCoordinates; 108 105 109 RetainPtr<WebHTMLView> htmlView = (WebHTMLView*)[[kit(&frame) frameView] documentView]; 106 110 if (![htmlView.get() isKindOfClass:[WebHTMLView class]]) 107 111 return; 108 112 109 NSEvent *event = drag SourceAction == DragSourceActionLink ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent];113 NSEvent *event = dragItem.sourceAction == DragSourceActionLink ? frame.eventHandler().currentNSEvent() : [htmlView.get() _mouseDownEvent]; 110 114 WebHTMLView* topHTMLView = getTopHTMLView(&frame); 111 115 RetainPtr<WebHTMLView> topViewProtector = topHTMLView; … … 125 129 if ([delegate respondsToSelector:selector]) { 126 130 @try { 127 [delegate webView:m_webView dragImage:dragNSImage at: atoffset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES forView:topHTMLView];131 [delegate webView:m_webView dragImage:dragNSImage at:dragLocationInContentCoordinates offset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES forView:topHTMLView]; 128 132 } @catch (id exception) { 129 133 ReportDiscardedDelegateException(selector, exception); … … 132 136 #pragma clang diagnostic push 133 137 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 134 [topHTMLView dragImage:dragNSImage at: atoffset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES];138 [topHTMLView dragImage:dragNSImage at:dragLocationInContentCoordinates offset:NSZeroSize event:event pasteboard:pasteboard source:sourceHTMLView slideBack:YES]; 135 139 #pragma clang diagnostic pop 136 140 } … … 199 203 } 200 204 201 void WebDragClient::startDrag(WebCore::DragI mage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, WebCore::DragSourceAction)205 void WebDragClient::startDrag(WebCore::DragItem, DataTransfer&, Frame&) 202 206 { 203 207 } … … 240 244 } 241 245 242 void WebDragClient::startDrag(DragI mage dragImage, const IntPoint& point, const IntPoint& eventLocation, const FloatPoint& dragImageAnchor, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)243 { 244 [m_webView _s etDataInteractionData:dragImage.get().get() textIndicator:dragImage.indicatorData() atClientPosition:eventLocation anchorPoint:dragImageAnchor action:dragSourceAction];246 void WebDragClient::startDrag(DragItem dragItem, DataTransfer&, Frame&) 247 { 248 [m_webView _startDrag:dragItem]; 245 249 } 246 250 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r218803 r218837 134 134 #import <WebCore/DragController.h> 135 135 #import <WebCore/DragData.h> 136 #import <WebCore/DragItem.h> 136 137 #import <WebCore/Editing.h> 137 138 #import <WebCore/Editor.h> … … 1830 1831 } 1831 1832 1832 - (void)_setDataInteractionData:(CGImageRef)image textIndicator:(std::optional<TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action 1833 { 1833 - (void)_startDrag:(const DragItem&)dragItem 1834 { 1835 auto& dragImage = dragItem.image; 1836 auto image = dragImage.get().get(); 1837 auto indicatorData = dragImage.indicatorData(); 1838 1834 1839 if (indicatorData) 1835 1840 _private->textIndicatorData = adoptNS([[WebUITextIndicatorData alloc] initWithImage:image textIndicatorData:indicatorData.value() scale:_private->page->deviceScaleFactor()]); -
trunk/Source/WebKit/mac/WebView/WebViewInternal.h
r217884 r218837 64 64 } 65 65 66 #if PLATFORM(IOS) && ENABLE(DRAG_SUPPORT) 67 namespace WebCore { 68 struct DragItem; 69 } 70 #endif 71 66 72 class WebMediaPlaybackTargetPicker; 67 73 class WebSelectionServiceController; … … 262 268 263 269 #if ENABLE(DATA_INTERACTION) && defined(__cplusplus) 264 - (void)_s etDataInteractionData:(CGImageRef)image textIndicator:(std::optional<WebCore::TextIndicatorData>)textIndicator atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;270 - (void)_startDrag:(const WebCore::DragItem&)dragItem; 265 271 - (void)_didConcludeEditDataInteraction; 266 272 #endif -
trunk/Source/WebKit/win/ChangeLog
r218794 r218837 1 2017-06-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag start codepaths to plumb a DragItem to client layers 4 https://bugs.webkit.org/show_bug.cgi?id=173832 5 Work towards <rdar://problem/32236827> 6 7 Reviewed by Ryosuke Niwa and Tim Horton. 8 9 Adjust for changes to WebDragClient::startDrag by pulling information out of DragItem. 10 11 * WebCoreSupport/WebDragClient.cpp: 12 (WebDragClient::startDrag): 13 * WebCoreSupport/WebDragClient.h: 14 1 15 2017-06-25 Konstantin Tokarev <annulen@yandex.ru> 2 16 -
trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.cpp
r214403 r218837 32 32 #include <WebCore/DragController.h> 33 33 #include <WebCore/DragData.h> 34 #include <WebCore/DragItem.h> 34 35 #include <WebCore/EventHandler.h> 35 36 #include <WebCore/FrameView.h> … … 99 100 } 100 101 101 void WebDragClient::startDrag(DragI mage image, const IntPoint& imageOrigin, const IntPoint& dragPoint, const FloatPoint&, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction)102 void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame& frame) 102 103 { 103 104 //FIXME: Allow UIDelegate to override behaviour <rdar://problem/5015953> 104 105 105 106 //We liberally protect everything, to protect against a load occurring mid-drag 107 auto& image = item.image; 108 auto imageOrigin = item.dragLocationInContentCoordinates; 109 auto dragPoint = item.eventPositionInContentCoordinates; 110 106 111 RefPtr<Frame> frameProtector = &frame; 107 112 COMPtr<IDragSourceHelper> helper; … … 126 131 sdi.ptOffset.x = dragPoint.x() - imageOrigin.x(); 127 132 sdi.ptOffset.y = dragPoint.y() - imageOrigin.y(); 128 if ( dragSourceAction == DragSourceActionLink)133 if (item.sourceAction == DragSourceActionLink) 129 134 sdi.ptOffset.y = b.bmHeight - sdi.ptOffset.y; 130 135 -
trunk/Source/WebKit/win/WebCoreSupport/WebDragClient.h
r214403 r218837 39 39 virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, const WebCore::DragData&); 40 40 virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&); 41 virtual void startDrag(WebCore::DragI mage, const WebCore::IntPoint&, const WebCore::IntPoint&, const WebCore::FloatPoint&, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction);41 virtual void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&); 42 42 43 43 private: -
trunk/Source/WebKit2/ChangeLog
r218834 r218837 1 2017-06-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag start codepaths to plumb a DragItem to client layers 4 https://bugs.webkit.org/show_bug.cgi?id=173832 5 Work towards <rdar://problem/32236827> 6 7 Reviewed by Ryosuke Niwa and Tim Horton. 8 9 Add support for serializing a DragItem over IPC. This encodes and decodes all members of DragItem except for the 10 PasteboardWriterData and the DragImage's image. The DragItem is sent over to the UI process in 11 WebDragClient::startDrag via the WebPageProxy::startDrag IPC message (renamed from WebPageProxy::setDragImage) 12 which now takes a DragItem. 13 14 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 15 (WebKit::WebPageProxy::startDrag): 16 (WebKit::WebPageProxy::setDragImage): Deleted. 17 * UIProcess/PageClient.h: 18 * UIProcess/WebPageProxy.h: 19 * UIProcess/WebPageProxy.messages.in: 20 21 Rename SetDragImage to StartDrag and refactor to receive only a DragItem and shareable bitmap handle. 22 23 * UIProcess/ios/PageClientImplIOS.h: 24 * UIProcess/ios/PageClientImplIOS.mm: 25 (WebKit::PageClientImpl::startDrag): 26 (WebKit::PageClientImpl::startDataInteractionWithImage): Deleted. 27 * UIProcess/ios/WKContentViewInteraction.h: 28 * UIProcess/ios/WKContentViewInteraction.mm: 29 (-[WKContentView _startDrag:item:]): 30 (-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]): Deleted. 31 32 Rename startDataInteractionWithImage to startDrag. 33 34 * UIProcess/mac/WebPageProxyMac.mm: 35 (WebKit::WebPageProxy::startDrag): 36 (WebKit::WebPageProxy::setDragImage): Deleted. 37 * WebProcess/WebCoreSupport/WebDragClient.cpp: 38 (WebKit::WebDragClient::startDrag): 39 * WebProcess/WebCoreSupport/WebDragClient.h: 40 * WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp: 41 (WebKit::WebDragClient::startDrag): 42 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 43 (WebKit::WebDragClient::startDrag): 44 1 45 2017-06-27 Wenson Hsieh <wenson_hsieh@apple.com> 2 46 -
trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
r218433 r218837 32 32 #import "PageClient.h" 33 33 #import "WebProcessProxy.h" 34 #import <WebCore/DragItem.h> 34 35 #import <WebCore/NotImplemented.h> 35 36 #import <WebCore/SearchPopupMenuCocoa.h> … … 105 106 #if PLATFORM(IOS) && ENABLE(DRAG_SUPPORT) 106 107 107 void WebPageProxy::s etDragImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<TextIndicatorData> textIndicator, const FloatPoint& dragImageAnchor, uint64_t action)108 void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle) 108 109 { 109 m_pageClient.startD ataInteractionWithImage(clientPosition, dragImageHandle, textIndicator, dragImageAnchor, action);110 m_pageClient.startDrag(dragItem, dragImageHandle); 110 111 } 111 112 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r218740 r218837 57 57 } 58 58 59 #if ENABLE(DRAG_SUPPORT) 60 namespace WebCore { 61 struct DragItem; 62 } 63 #endif 64 59 65 namespace WebKit { 60 66 … … 374 380 virtual void didPerformDataInteractionControllerOperation(bool handled) = 0; 375 381 virtual void didHandleStartDataInteractionRequest(bool started) = 0; 376 virtual void startD ataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) = 0;382 virtual void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) = 0; 377 383 virtual void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) = 0; 378 384 virtual void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r218750 r218837 833 833 void setDragCaretRect(const WebCore::IntRect&); 834 834 #if PLATFORM(COCOA) 835 void s etDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& dragImageAnchor, uint64_t action);835 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& dragImageHandle); 836 836 void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::Handle& imageHandle, uint64_t imageSize, const String& filename, const String& extension, 837 837 const String& title, const String& url, const String& visibleURL, const SharedMemory::Handle& archiveHandle, uint64_t archiveSize); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r218750 r218837 303 303 #endif 304 304 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT) 305 S etDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, std::optional<WebCore::TextIndicatorData> textIndicator, WebCore::FloatPoint dragImageAnchor, uint64_t action)305 StartDrag(struct WebCore::DragItem dragItem, WebKit::ShareableBitmap::Handle dragImage) 306 306 SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize) 307 307 #if ENABLE(ATTACHMENT_ELEMENT) -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
r218457 r218837 209 209 void didPerformDataInteractionControllerOperation(bool handled) override; 210 210 void didHandleStartDataInteractionRequest(bool started) override; 211 void startD ataInteractionWithImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData>, const WebCore::FloatPoint& anchorPoint, uint64_t action) override;211 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override; 212 212 void didConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData>) override; 213 213 void didChangeDataInteractionCaretRect(const WebCore::IntRect& previousCaretRect, const WebCore::IntRect& caretRect) override; -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r218457 r218837 787 787 } 788 788 789 void PageClientImpl::startD ataInteractionWithImage(const IntPoint& clientPosition, const ShareableBitmap::Handle& image, std::optional<WebCore::TextIndicatorData> indicatorData, const FloatPoint& anchorPoint, uint64_t action)790 { 791 [m_contentView _startD ataInteractionWithImage:ShareableBitmap::create(image)->makeCGImageCopy() withIndicatorData:indicatorData atClientPosition:CGPointMake(clientPosition.x(), clientPosition.y()) anchorPoint:anchorPoint action:action];789 void PageClientImpl::startDrag(const DragItem& item, const ShareableBitmap::Handle& image) 790 { 791 [m_contentView _startDrag:ShareableBitmap::create(image)->makeCGImageCopy() item:item]; 792 792 } 793 793 -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
r218606 r218837 57 57 class TextStream; 58 58 } 59 60 #if ENABLE(DRAG_SUPPORT) 61 namespace WebCore { 62 struct DragItem; 63 } 64 #endif 59 65 60 66 namespace WebKit { … … 330 336 - (void)_didPerformDataInteractionControllerOperation:(BOOL)handled; 331 337 - (void)_didHandleStartDataInteractionRequest:(BOOL)started; 332 - (void)_startD ataInteractionWithImage:(RetainPtr<CGImageRef>)image withIndicatorData:(std::optional<WebCore::TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;338 - (void)_startDrag:(RetainPtr<CGImageRef>)image item:(const WebCore::DragItem&)item; 333 339 - (void)_didConcludeEditDataInteraction:(std::optional<WebCore::TextIndicatorData>)data; 334 340 - (void)_didChangeDataInteractionCaretRect:(CGRect)previousRect currentRect:(CGRect)rect; -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r218834 r218837 102 102 #import <UIKit/_UITextDragCaretView.h> 103 103 #import <WebCore/DragData.h> 104 #import <WebCore/DragItem.h> 104 105 #import <WebCore/PlatformPasteboard.h> 105 106 #import <WebCore/WebItemProviderPasteboard.h> … … 4221 4222 } 4222 4223 4223 - (void)_startDataInteractionWithImage:(RetainPtr<CGImageRef>)image withIndicatorData:(std::optional<TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action 4224 { 4225 ASSERT(action != DragSourceActionNone); 4224 - (void)_startDrag:(RetainPtr<CGImageRef>)image item:(const DragItem&)item 4225 { 4226 ASSERT(item.sourceAction != DragSourceActionNone); 4227 4226 4228 _dataInteractionState.image = adoptNS([[UIImage alloc] initWithCGImage:image.get() scale:_page->deviceScaleFactor() orientation:UIImageOrientationUp]); 4227 _dataInteractionState.indicatorData = i ndicatorData;4228 _dataInteractionState.sourceAction = static_cast<DragSourceAction>( action);4229 _dataInteractionState.indicatorData = item.image.indicatorData(); 4230 _dataInteractionState.sourceAction = static_cast<DragSourceAction>(item.sourceAction); 4229 4231 } 4230 4232 -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r218457 r218837 49 49 #import <WebCore/DictationAlternative.h> 50 50 #import <WebCore/DictionaryLookup.h> 51 #import <WebCore/DragItem.h> 51 52 #import <WebCore/GraphicsLayer.h> 52 53 #import <WebCore/NSApplicationSPI.h> … … 270 271 271 272 #if ENABLE(DRAG_SUPPORT) 272 void WebPageProxy::s etDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, std::optional<TextIndicatorData>, const FloatPoint&, uint64_t action)273 void WebPageProxy::startDrag(const DragItem& dragItem, const ShareableBitmap::Handle& dragImageHandle) 273 274 { 274 275 if (auto dragImage = ShareableBitmap::create(dragImageHandle)) 275 m_pageClient.setDragImage( clientPosition, dragImage.releaseNonNull(), static_cast<DragSourceAction>(action));276 m_pageClient.setDragImage(dragItem.dragLocationInWindowCoordinates, dragImage.releaseNonNull(), static_cast<DragSourceAction>(dragItem.sourceAction)); 276 277 277 278 didStartDrag(); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
r214403 r218837 53 53 54 54 #if !PLATFORM(COCOA) && !PLATFORM(GTK) 55 void WebDragClient::startDrag(DragI mage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, DragSourceAction)55 void WebDragClient::startDrag(DragItem, DataTransfer&, Frame&) 56 56 { 57 57 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.h
r214403 r218837 47 47 WebCore::DragSourceAction dragSourceActionMaskForPoint(const WebCore::IntPoint& windowPoint) override; 48 48 49 void startDrag(WebCore::DragI mage, const WebCore::IntPoint& dragImageOrigin, const WebCore::IntPoint& eventPos, const WebCore::FloatPoint& dragImageAnchor, WebCore::DataTransfer&, WebCore::Frame&, WebCore::DragSourceAction) override;49 void startDrag(WebCore::DragItem, WebCore::DataTransfer&, WebCore::Frame&) override; 50 50 void didConcludeEditDrag() override; 51 51 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDragClientGtk.cpp
r213627 r218837 61 61 } 62 62 63 void WebDragClient::startDrag(DragI mage dragImage, const IntPoint& clientPosition, const IntPoint& globalPosition, const FloatPoint&, DataTransfer& dataTransfer, Frame&, DragSourceAction)63 void WebDragClient::startDrag(DragItem item, DataTransfer& dataTransfer, Frame&) 64 64 { 65 auto& dragImage = item.image; 65 66 RefPtr<ShareableBitmap> bitmap = convertCairoSurfaceToShareableBitmap(dragImage.get().get()); 66 67 ShareableBitmap::Handle handle; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r218433 r218837 93 93 } 94 94 95 void WebDragClient::startDrag(DragImage image, const IntPoint& point, const IntPoint&, const FloatPoint&, DataTransfer&, Frame& frame, DragSourceAction dragSourceAction) 96 { 95 void WebDragClient::startDrag(DragItem dragItem, DataTransfer&, Frame& frame) 96 { 97 auto& image = dragItem.image; 97 98 IntSize bitmapSize([image.get() size]); 98 99 RefPtr<ShareableBitmap> bitmap = convertImageToBitmap(image.get().get(), bitmapSize, frame); … … 102 103 103 104 m_page->willStartDrag(); 104 105 // FIXME: Seems this message should be named StartDrag, not SetDragImage. 106 m_page->send(Messages::WebPageProxy::SetDragImage(frame.view()->contentsToWindow(point), handle, std::nullopt, { }, dragSourceAction)); 105 m_page->send(Messages::WebPageProxy::StartDrag(dragItem, handle)); 107 106 } 108 107 … … 208 207 } 209 208 210 void WebDragClient::startDrag(DragImage image, const IntPoint& point, const IntPoint& eventLocation, const FloatPoint& dragImageAnchor, DataTransfer& dataTransfer, Frame& frame, DragSourceAction dragSourceAction) 211 { 209 void WebDragClient::startDrag(DragItem dragItem, DataTransfer& dataTransfer, Frame& frame) 210 { 211 auto& image = dragItem.image; 212 212 213 IntSize bitmapSize(CGImageGetWidth(image.get().get()), CGImageGetHeight(image.get().get())); 213 214 auto bitmap = convertCGImageToBitmap(image.get().get(), bitmapSize, frame); … … 217 218 218 219 m_page->willStartDrag(); 219 m_page->send(Messages::WebPageProxy::S etDragImage(frame.view()->contentsToWindow(point), handle, image.indicatorData(), dragImageAnchor, dragSourceAction));220 m_page->send(Messages::WebPageProxy::StartDrag(dragItem, handle)); 220 221 } 221 222
Note: See TracChangeset
for help on using the changeset viewer.