Changeset 211192 in webkit
- Timestamp:
- Jan 25, 2017 6:01:29 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211191 r211192 1 2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag and drop implementation on Mac 4 https://bugs.webkit.org/show_bug.cgi?id=167427 5 6 Reviewed by Enrica Casucci. 7 8 Refactors some code around drag and drop on Mac, and cleans up some other related code as needed. This patch 9 should result in no behavior change. 10 11 * dom/DataTransfer.cpp: 12 * page/EventHandler.cpp: 13 * page/ios/EventHandlerIOS.mm: 14 (WebCore::EventHandler::eventLoopHandleMouseDragged): 15 * page/mac/EventHandlerMac.mm: 16 * platform/DragImage.cpp: 17 * platform/Pasteboard.h: 18 * platform/ios/DragImageIOS.mm: 19 * platform/ios/PasteboardIOS.mm: 20 * platform/mac/DragDataMac.mm: 21 (rtfPasteboardType): 22 (rtfdPasteboardType): 23 (stringPasteboardType): 24 (urlPasteboardType): 25 (htmlPasteboardType): 26 (colorPasteboardType): 27 (pdfPasteboardType): 28 (tiffPasteboardType): 29 (WebCore::DragData::DragData): 30 (WebCore::DragData::containsColor): 31 (WebCore::DragData::containsFiles): 32 (WebCore::DragData::numberOfFiles): 33 (WebCore::DragData::asFilenames): 34 (WebCore::DragData::containsPlainText): 35 (WebCore::DragData::containsCompatibleContent): 36 (WebCore::DragData::containsPromise): 37 (WebCore::DragData::asURL): 38 * platform/mac/DragImageMac.mm: 39 1 40 2017-01-25 Youenn Fablet <youenn@apple.com> 2 41 -
trunk/Source/WebCore/dom/DataTransfer.cpp
r210006 r211192 291 291 } 292 292 293 #if !PLATFORM( COCOA)293 #if !PLATFORM(MAC) 294 294 295 295 DragImageRef DataTransfer::createDragImage(IntPoint& location) const -
trunk/Source/WebCore/page/EventHandler.cpp
r211033 r211192 132 132 const int TextDragHysteresis = 3; 133 133 const int GeneralDragHysteresis = 3; 134 #if PLATFORM(COCOA) 135 const double EventHandler::TextDragDelay = 0.15; 136 #endif 134 137 #endif // ENABLE(DRAG_SUPPORT) 135 138 … … 807 810 808 811 #if ENABLE(DRAG_SUPPORT) 809 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event )812 bool EventHandler::handleMouseDraggedEvent(const MouseEventWithHitTestResults& event, CheckDragHysteresis checkDragHysteresis) 810 813 { 811 814 if (!m_mousePressed) … … 814 817 Ref<Frame> protectedFrame(m_frame); 815 818 816 if (handleDrag(event, ShouldCheckDragHysteresis))819 if (handleDrag(event, checkDragHysteresis)) 817 820 return true; 818 821 -
trunk/Source/WebCore/page/EventHandler.h
r211033 r211192 339 339 340 340 #if ENABLE(DRAG_SUPPORT) 341 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults& );341 bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis); 342 342 #endif 343 343 -
trunk/Source/WebCore/page/ios/EventHandlerIOS.mm
r211033 r211192 48 48 #if ENABLE(IOS_TOUCH_EVENTS) 49 49 #import <WebKitAdditions/EventHandlerIOSTouch.cpp> 50 #endif 51 52 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/EventHandlerAdditions.mm>) 53 #import <WebKitAdditions/EventHandlerAdditions.mm> 50 54 #endif 51 55 -
trunk/Source/WebCore/page/mac/EventHandlerMac.mm
r211033 r211192 75 75 namespace WebCore { 76 76 77 #if ENABLE(DRAG_SUPPORT)78 const double EventHandler::TextDragDelay = 0.15;79 #endif80 81 77 const double resetLatchedStateTimeout = 0.1; 82 78 -
trunk/Source/WebCore/platform/DragImage.cpp
r208985 r211192 121 121 } 122 122 123 #if !ENABLE(DATA_INTERACTION) 124 123 125 DragImageRef createDragImageForSelection(Frame& frame, bool forceBlackText) 124 126 { … … 126 128 return createDragImageFromSnapshot(snapshotSelection(frame, options), nullptr); 127 129 } 130 131 #endif 128 132 129 133 struct ScopedFrameSelectionState { -
trunk/Source/WebCore/platform/Pasteboard.h
r211158 r211192 130 130 struct PasteboardPlainText { 131 131 String text; 132 #if PLATFORM( MAC)132 #if PLATFORM(COCOA) 133 133 bool isURL; 134 134 #endif … … 180 180 181 181 #if ENABLE(DRAG_SUPPORT) 182 static std::unique_ptr<Pasteboard> createForDragAndDrop();183 static std::unique_ptr<Pasteboard> createForDragAndDrop(const DragData&);182 WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForDragAndDrop(); 183 WEBCORE_EXPORT static std::unique_ptr<Pasteboard> createForDragAndDrop(const DragData&); 184 184 185 185 virtual void setDragImage(DragImageRef, const IntPoint& hotSpot); -
trunk/Source/WebCore/platform/ios/DragImageIOS.mm
r165676 r211192 29 29 #import <CoreGraphics/CoreGraphics.h> 30 30 31 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/DragImageAdditions.mm>) 32 33 #import <WebKitAdditions/DragImageAdditions.mm> 34 35 #else 36 31 37 namespace WebCore { 32 38 … … 50 56 51 57 } // namespace WebCore 58 59 #endif // USE(APPLE_INTERNAL_SDK) -
trunk/Source/WebCore/platform/ios/PasteboardIOS.mm
r211158 r211192 59 59 @end 60 60 61 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PasteboardAdditions.mm>) 62 #import <WebKitAdditions/PasteboardAdditions.mm> 63 #endif 64 61 65 namespace WebCore { 62 66 -
trunk/Source/WebCore/platform/mac/DragDataMac.mm
r210360 r211192 34 34 #import "WebCoreNSURLExtras.h" 35 35 36 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/DragDataAdditions.mm>) 37 38 #import <WebKitAdditions/DragDataAdditions.mm> 39 40 #else 41 42 static inline String rtfPasteboardType() 43 { 44 return String(NSRTFPboardType); 45 } 46 47 static inline String rtfdPasteboardType() 48 { 49 return String(NSRTFDPboardType); 50 } 51 52 static inline String stringPasteboardType() 53 { 54 return String(NSStringPboardType); 55 } 56 57 static inline String urlPasteboardType() 58 { 59 return String(NSURLPboardType); 60 } 61 62 static inline String htmlPasteboardType() 63 { 64 return String(NSHTMLPboardType); 65 } 66 67 static inline String colorPasteboardType() 68 { 69 return String(NSColorPboardType); 70 } 71 72 static inline String pdfPasteboardType() 73 { 74 return String(NSPDFPboardType); 75 } 76 77 static inline String tiffPasteboardType() 78 { 79 return String(NSTIFFPboardType); 80 } 81 82 #endif // USE(APPLE_INTERNAL_SDK) 83 36 84 namespace WebCore { 37 85 … … 43 91 , m_draggingSourceOperationMask(sourceOperationMask) 44 92 , m_applicationFlags(flags) 93 #if PLATFORM(MAC) 45 94 , m_pasteboardName([[m_platformDragData draggingPasteboard] name]) 95 #else 96 , m_pasteboardName("data interaction pasteboard") 97 #endif 46 98 { 47 99 } … … 67 119 Vector<String> types; 68 120 platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName); 69 return types.contains( String(NSColorPboardType));121 return types.contains(colorPasteboardType()); 70 122 } 71 123 72 124 bool DragData::containsFiles() const 73 125 { 126 #if PLATFORM(MAC) 74 127 Vector<String> types; 75 128 platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName); 76 129 return types.contains(String(NSFilenamesPboardType)) || types.contains(String(NSFilesPromisePboardType)); 130 #else 131 return false; 132 #endif 77 133 } 78 134 … … 80 136 { 81 137 Vector<String> files; 138 #if PLATFORM(MAC) 82 139 platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName); 83 140 if (!files.size()) 84 141 platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName); 142 #endif 85 143 return files.size(); 86 144 } … … 88 146 void DragData::asFilenames(Vector<String>& result) const 89 147 { 148 #if PLATFORM(MAC) 90 149 platformStrategies()->pasteboardStrategy()->getPathnamesForType(result, String(NSFilenamesPboardType), m_pasteboardName); 91 150 if (!result.size()) 92 151 result = fileNames(); 152 #else 153 UNUSED_PARAM(result); 154 #endif 93 155 } 94 156 … … 98 160 platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName); 99 161 100 return types.contains(String(NSStringPboardType)) 101 || types.contains(String(NSRTFDPboardType)) 102 || types.contains(String(NSRTFPboardType)) 162 return types.contains(stringPasteboardType()) 163 || types.contains(rtfdPasteboardType()) 164 || types.contains(rtfPasteboardType()) 165 #if PLATFORM(MAC) 103 166 || types.contains(String(NSFilenamesPboardType)) 104 || platformStrategies()->pasteboardStrategy()->stringForType(String(NSURLPboardType), m_pasteboardName).length(); 167 #endif 168 || platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName).length(); 105 169 } 106 170 … … 131 195 platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName); 132 196 return types.contains(String(WebArchivePboardType)) 133 || types.contains(String(NSHTMLPboardType)) 197 || types.contains(htmlPasteboardType()) 198 #if PLATFORM(MAC) 134 199 || types.contains(String(NSFilenamesPboardType)) 135 200 || types.contains(String(NSFilesPromisePboardType)) 136 || types.contains(String(NSTIFFPboardType)) 137 || types.contains(String(NSPDFPboardType)) 138 || types.contains(String(NSURLPboardType)) 139 || types.contains(String(NSRTFDPboardType)) 140 || types.contains(String(NSRTFPboardType)) 141 || types.contains(String(NSStringPboardType)) 142 || types.contains(String(NSColorPboardType)) 201 #endif 202 || types.contains(tiffPasteboardType()) 203 || types.contains(pdfPasteboardType()) 204 || types.contains(urlPasteboardType()) 205 || types.contains(rtfdPasteboardType()) 206 || types.contains(rtfPasteboardType()) 207 || types.contains(stringPasteboardType()) 208 || types.contains(colorPasteboardType()) 143 209 || types.contains(String(kUTTypePNG)); 144 210 } … … 147 213 { 148 214 Vector<String> files; 215 #if PLATFORM(MAC) 149 216 platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilesPromisePboardType), m_pasteboardName); 217 #endif 150 218 return files.size() == 1; 151 219 } … … 161 229 162 230 if (title) { 231 #if PLATFORM(MAC) 163 232 String URLTitleString = platformStrategies()->pasteboardStrategy()->stringForType(String(WebURLNamePboardType), m_pasteboardName); 164 233 if (!URLTitleString.isEmpty()) 165 234 *title = URLTitleString; 166 } 167 168 Vector<String> types; 169 platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName); 170 171 if (types.contains(String(NSURLPboardType))) { 172 NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(String(NSURLPboardType), m_pasteboardName)]; 235 #endif 236 } 237 238 Vector<String> types; 239 platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName); 240 241 if (types.contains(urlPasteboardType())) { 242 NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(urlPasteboardType(), m_pasteboardName)]; 173 243 NSString *scheme = [URLFromPasteboard scheme]; 174 244 // Cannot drop other schemes unless <rdar://problem/10562662> and <rdar://problem/11187315> are fixed. … … 177 247 } 178 248 179 if (types.contains( String(NSStringPboardType))) {180 NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType( String(NSStringPboardType), m_pasteboardName)];249 if (types.contains(stringPasteboardType())) { 250 NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(stringPasteboardType(), m_pasteboardName)]; 181 251 NSString *scheme = [URLFromPasteboard scheme]; 182 252 // Pasteboard content is not trusted, because JavaScript code can modify it. We can sanitize it for URLs and other typed content, but not for strings. … … 187 257 } 188 258 259 #if PLATFORM(MAC) 189 260 if (types.contains(String(NSFilenamesPboardType))) { 190 261 Vector<String> files; … … 200 271 if (types.contains(String(NSFilesPromisePboardType)) && fileNames().size() == 1) 201 272 return [URLByCanonicalizingURL([NSURL fileURLWithPath:fileNames()[0]]) absoluteString]; 273 #endif 202 274 203 275 return String(); -
trunk/Source/WebCore/platform/mac/DragImageMac.mm
r208455 r211192 27 27 #import "DragImage.h" 28 28 29 #if ENABLE(DRAG_SUPPORT) 29 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 30 30 31 31 #import "BitmapImage.h" … … 349 349 } // namespace WebCore 350 350 351 #endif // ENABLE(DRAG_SUPPORT) 351 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) -
trunk/Source/WebKit/mac/ChangeLog
r211161 r211192 1 2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag and drop implementation on Mac 4 https://bugs.webkit.org/show_bug.cgi?id=167427 5 6 Reviewed by Enrica Casucci. 7 8 Refactor some WebKit1 code on the Mac pertaining to drag and drop. See WebCore ChangeLog for more details. 9 10 * Misc/WebNSPasteboardExtras.h: 11 * WebCoreSupport/WebDragClient.mm: 12 * WebView/WebFrame.mm: 13 * WebView/WebFrameInternal.h: 14 * WebView/WebHTMLView.mm: 15 * WebView/WebView.mm: 16 (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]): 17 1 18 2017-01-24 Youenn Fablet <youennf@gmail.com> 2 19 -
trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
r208904 r211192 26 26 #import "WebDragClient.h" 27 27 28 #if ENABLE(DRAG_SUPPORT) 28 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 29 29 30 30 #import "DOMElementInternal.h" … … 144 144 } 145 145 146 #endif // ENABLE(DRAG_SUPPORT) 146 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) -
trunk/Source/WebKit/mac/WebView/WebFrame.mm
r211033 r211192 934 934 } 935 935 936 #if ENABLE(DRAG_SUPPORT) 936 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 937 937 - (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation 938 938 { … … 947 947 _private->coreFrame->eventHandler().dragSourceEndedAt(event, (DragOperation)operation); 948 948 } 949 #endif 949 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 950 950 951 951 - (BOOL)_canProvideDocumentSource -
trunk/Source/WebKit/mac/WebView/WebFrameInternal.h
r196489 r211192 180 180 - (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(WebCore::EditAction)undoAction; 181 181 182 #if ENABLE(DRAG_SUPPORT) 182 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 183 183 - (void)_dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation; 184 184 #endif -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r210779 r211192 4545 4545 #endif 4546 4546 4547 #if ENABLE(DRAG_SUPPORT) 4547 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 4548 4548 - (void)dragImage:(NSImage *)dragImage 4549 4549 at:(NSPoint)at … … 4689 4689 return [NSArray arrayWithObject:[path lastPathComponent]]; 4690 4690 } 4691 #endif 4691 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 4692 4692 4693 4693 #if !PLATFORM(IOS) -
trunk/Source/WebKit/mac/WebView/WebView.mm
r211161 r211192 1609 1609 ); 1610 1610 pageConfiguration.chromeClient = new WebChromeClientIOS(self); 1611 #if ENABLE(DRAG_SUPPORT) 1611 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 1612 1612 pageConfiguration.dragClient = new WebDragClient(self); 1613 1613 #endif … … 6476 6476 } 6477 6477 6478 #if ENABLE(DRAG_SUPPORT) 6478 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 6479 6479 // The following 2 internal NSView methods are called on the drag destination to make scrolling while dragging work. 6480 6480 // Scrolling while dragging will only work if the drag destination is in a scroll view. The WebView is the drag destination. … … 6597 6597 return hitView; 6598 6598 } 6599 #endif 6599 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) 6600 6600 6601 6601 - (BOOL)acceptsFirstResponder -
trunk/Source/WebKit2/ChangeLog
r211172 r211192 1 2017-01-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Refactor drag and drop implementation on Mac 4 https://bugs.webkit.org/show_bug.cgi?id=167427 5 6 Reviewed by Enrica Casucci. 7 8 See WebCore ChangeLog for more details. 9 10 * Shared/WebCoreArgumentCoders.cpp: 11 (IPC::ArgumentCoder<DragData>::encode): 12 (IPC::ArgumentCoder<DragData>::decode): 13 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 14 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 15 1 16 2017-01-25 Andy Estes <aestes@apple.com> 2 17 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r210560 r211192 1224 1224 encoder.encodeEnum(dragData.draggingSourceOperationMask()); 1225 1225 encoder.encodeEnum(dragData.flags()); 1226 #if PLATFORM(COCOA) 1227 encoder << dragData.pasteboardName(); 1228 #endif 1226 1229 #if PLATFORM(MAC) 1227 encoder << dragData.pasteboardName();1228 1230 encoder << dragData.fileNames(); 1229 1231 #endif … … 1249 1251 1250 1252 String pasteboardName; 1253 #if PLATFORM(COCOA) 1254 if (!decoder.decode(pasteboardName)) 1255 return false; 1256 #endif 1257 Vector<String> fileNames; 1251 1258 #if PLATFORM(MAC) 1252 if (!decoder.decode(pasteboardName))1253 return false;1254 #endif1255 Vector<String> fileNames;1256 1259 if (!decoder.decode(fileNames)) 1257 1260 return false; 1261 #endif 1258 1262 1259 1263 dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags); -
trunk/Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
r208361 r211192 34 34 #import <WebCore/ValidationBubble.h> 35 35 #import <wtf/cf/TypeCastsCF.h> 36 37 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebPageProxyAdditions.mm>) 38 #import <WebKitAdditions/WebPageProxyAdditions.mm> 39 #endif 36 40 37 41 namespace WebKit { -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r208596 r211192 51 51 using namespace WebCore; 52 52 using namespace WebKit; 53 54 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebDragClientAdditions.mm>) 55 #import <WebKitAdditions/WebDragClientAdditions.mm> 56 #endif 57 58 #if PLATFORM(MAC) 53 59 54 60 namespace WebKit { … … 161 167 } // namespace WebKit 162 168 169 #endif // PLATFORM(MAC) 170 163 171 #endif // ENABLE(DRAG_SUPPORT)
Note: See TracChangeset
for help on using the changeset viewer.