Changeset 213176 in webkit
- Timestamp:
- Feb 28, 2017 2:11:07 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r213175 r213176 1 2017-02-28 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Data interaction should support attachment elements 4 https://bugs.webkit.org/show_bug.cgi?id=168916 5 <rdar://problem/30664519> 6 7 Reviewed by Ryosuke Niwa. 8 9 Teaches DragController to recognize and initiate dragging on attachment elements, and also adds a new 10 convenience method to the WebItemProviderPasteboard for block enumeration of available UIItemProviders. Covered 11 by a new API test: DataInteractionTests.AttachmentElementItemProviders. 12 13 * page/DragController.cpp: 14 (WebCore::DragController::draggableElement): 15 (WebCore::DragController::startDrag): 16 * platform/ios/WebItemProviderPasteboard.h: 17 * platform/ios/WebItemProviderPasteboard.mm: 18 (-[WebItemProviderPasteboard enumerateItemProvidersWithBlock:]): 19 1 20 2017-02-28 Mark Lam <mark.lam@apple.com> 2 21 -
trunk/Source/WebCore/page/DragController.cpp
r212930 r213176 65 65 #include "PluginDocument.h" 66 66 #include "PluginViewBase.h" 67 #include "Position.h" 67 68 #include "RenderFileUploadControl.h" 68 69 #include "RenderImage.h" … … 76 77 #include "Text.h" 77 78 #include "TextEvent.h" 79 #include "VisiblePosition.h" 78 80 #include "htmlediting.h" 79 81 #include "markup.h" … … 655 657 return nullptr; 656 658 #if ENABLE(ATTACHMENT_ELEMENT) 657 // Unlike image elements, attachment elements are immediately selected upon mouse down, 658 // but for those elements we still want to use the single element drag behavior as long as 659 // the element is the only content of the selection. 660 const VisibleSelection& selection = sourceFrame->selection().selection(); 661 if (selection.isRange() && is<HTMLAttachmentElement>(selection.start().anchorNode()) && selection.start().anchorNode() == selection.end().anchorNode()) 662 state.type = DragSourceActionNone; 659 if (is<HTMLAttachmentElement>(startElement)) { 660 auto selection = sourceFrame->selection().selection(); 661 bool isSingleAttachmentSelection = selection.start() == Position(startElement, Position::PositionIsBeforeAnchor) && selection.end() == Position(startElement, Position::PositionIsAfterAnchor); 662 bool isAttachmentElementInCurrentSelection = false; 663 if (auto selectedRange = selection.toNormalizedRange()) { 664 auto compareResult = selectedRange->compareNode(*startElement); 665 isAttachmentElementInCurrentSelection = !compareResult.hasException() && compareResult.releaseReturnValue() == Range::NODE_INSIDE; 666 } 667 668 if (!isAttachmentElementInCurrentSelection || isSingleAttachmentSelection) { 669 state.type = DragSourceActionAttachment; 670 return startElement; 671 } 672 } 663 673 #endif 664 674 … … 998 1008 999 1009 #if ENABLE(ATTACHMENT_ELEMENT) 1000 if ( !attachmentURL.isEmpty() && (m_dragSourceAction & DragSourceActionAttachment)) {1010 if (m_dragSourceAction & DragSourceActionAttachment) { 1001 1011 if (!dataTransfer.pasteboard().hasData()) { 1002 m_draggingAttachmentURL = attachmentURL;1003 1012 selectElement(element); 1004 declareAndWriteAttachment(dataTransfer, element, attachmentURL); 1013 if (!attachmentURL.isEmpty()) { 1014 // Use the attachment URL specified by the file attribute to populate the pasteboard. 1015 m_draggingAttachmentURL = attachmentURL; 1016 declareAndWriteAttachment(dataTransfer, element, attachmentURL); 1017 } else if (src.editor().client()) { 1018 #if PLATFORM(COCOA) 1019 // Otherwise, if no file URL is specified, call out to the injected bundle to populate the pasteboard with data. 1020 auto& editor = src.editor(); 1021 editor.willWriteSelectionToPasteboard(src.selection().toNormalizedRange()); 1022 editor.writeSelectionToPasteboard(dataTransfer.pasteboard()); 1023 editor.didWriteSelectionToPasteboard(); 1024 #endif 1025 } 1005 1026 } 1006 1027 -
trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h
r211716 r213176 46 46 - (void)decrementPendingOperationCount; 47 47 48 - (void)enumerateItemProvidersWithBlock:(void (^)(UIItemProvider *itemProvider, NSUInteger index, BOOL *stop))block; 49 48 50 @end 49 51 -
trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm
r212734 r213176 249 249 } 250 250 251 - (void)enumerateItemProvidersWithBlock:(void (^)(UIItemProvider *itemProvider, NSUInteger index, BOOL *stop))block 252 { 253 [_itemProviders enumerateObjectsUsingBlock:block]; 254 } 255 251 256 @end 252 257 -
trunk/Source/WebKit2/ChangeLog
r213170 r213176 1 2017-02-28 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Data interaction should support attachment elements 4 https://bugs.webkit.org/show_bug.cgi?id=168916 5 <rdar://problem/30664519> 6 7 Reviewed by Ryosuke Niwa. 8 9 Teaches WKContentView to recognize attachment elements as data interactive content, and add an internal hook to 10 adjust the list of item providers before initiating data interaction. 11 12 * Platform/spi/ios/UIKitSPI.h: 13 * UIProcess/API/Cocoa/WKWebView.mm: 14 (-[WKWebView _adjustedDataInteractionItemProviders:]): 15 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 16 * UIProcess/ios/WKContentViewInteraction.mm: 17 (-[WKContentView pointIsInDataInteractionContent:]): 18 1 19 2017-02-28 Yongjun Zhang <yongjun_zhang@apple.com> 2 20 -
trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h
r212974 r213176 41 41 #import <UIKit/UIImage_Private.h> 42 42 #import <UIKit/UIInterface_Private.h> 43 #import <UIKit/UIItemProvider_Private.h> 43 44 #import <UIKit/UIKeyboardImpl.h> 44 45 #import <UIKit/UIKeyboardIntl.h> -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r212974 r213176 3727 3727 } 3728 3728 3729 - (NSArray *)_adjustedDataInteractionItemProviders:(NSArray *)originalItemProviders 3730 { 3731 return originalItemProviders; 3732 } 3733 3729 3734 #endif 3730 3735 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r212974 r213176 189 189 - (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content; 190 190 191 - (NSArray *)_adjustedDataInteractionItemProviders:(NSArray *)originalItemProviders WK_API_AVAILABLE(ios(WK_IOS_TBA)); 192 191 193 #else 192 194 @property (readonly) NSColor *_pageExtendedBackgroundColor; -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r213170 r213176 1438 1438 [self ensurePositionInformationIsUpToDate:request]; 1439 1439 1440 if (_positionInformation.isImage || _positionInformation.isLink )1440 if (_positionInformation.isImage || _positionInformation.isLink || _positionInformation.isAttachment) 1441 1441 return YES; 1442 1442 -
trunk/Tools/ChangeLog
r213169 r213176 1 2017-02-28 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Data interaction should support attachment elements 4 https://bugs.webkit.org/show_bug.cgi?id=168916 5 <rdar://problem/30664519> 6 7 Reviewed by Ryosuke Niwa. 8 9 Adds a new unit test verifying that a client injected bundle is able to augment UIItemProvider data vended to 10 the UI process. 11 12 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 13 * TestWebKitAPI/Tests/WebKit2Cocoa/attachment-element.html: Added. 14 * TestWebKitAPI/Tests/ios/DataInteractionTests.mm: 15 (-[CustomItemProviderWebView _adjustedDataInteractionItemProviders:]): 16 (TestWebKitAPI::TEST): 17 1 18 2017-02-28 Chris Dumez <cdumez@apple.com> 2 19 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r213163 r213176 562 562 F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; }; 563 563 F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */; }; 564 F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4856CA21E6498A8009D7EE7 /* attachment-element.html */; }; 564 565 F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; }; 565 566 F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; }; … … 640 641 dstSubfolderSpec = 7; 641 642 files = ( 643 F4856CA31E649EA8009D7EE7 /* attachment-element.html in Copy Resources */, 642 644 8361F1781E610B4E00759B25 /* link-with-download-attribute-with-slashes.html in Copy Resources */, 643 645 F4FA91831E61857B007B8C1D /* double-click-does-not-select-trailing-space.html in Copy Resources */, … … 1396 1398 F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKit2Cocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; }; 1397 1399 F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-page-contenteditable.html"; sourceTree = "<group>"; }; 1400 F4856CA21E6498A8009D7EE7 /* attachment-element.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "attachment-element.html"; sourceTree = "<group>"; }; 1398 1401 F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = "<group>"; }; 1399 1402 F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; }; … … 1807 1810 C25CCA0A1E513F490026CB8A /* LineBreaking.html */, 1808 1811 C25CCA0C1E5140E50026CB8A /* AllAhem.svg */, 1812 F4856CA21E6498A8009D7EE7 /* attachment-element.html */, 1809 1813 ); 1810 1814 name = Resources; -
trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
r213091 r213176 31 31 #import "PlatformUtilities.h" 32 32 #import "TestWKWebView.h" 33 #import "WKWebViewConfigurationExtras.h" 33 34 #import <MobileCoreServices/MobileCoreServices.h> 34 35 #import <UIKit/UIItemProvider_Private.h> 36 #import <WebKit/WKWebViewConfigurationPrivate.h> 37 #import <WebKit/WKWebViewPrivate.h> 35 38 36 39 @implementation TestWKWebView (DataInteractionTests) … … 44 47 { 45 48 return [self stringByEvaluatingJavaScript:@"editor.value"]; 49 } 50 51 @end 52 53 @interface CustomItemProviderWebView : TestWKWebView 54 @property (nonatomic) BlockPtr<NSArray *(NSArray *)> convertItemProvidersBlock; 55 @end 56 57 @implementation CustomItemProviderWebView 58 59 - (NSArray *)_adjustedDataInteractionItemProviders:(NSArray *)originalItemProviders 60 { 61 if (!self.convertItemProvidersBlock) 62 return [super _adjustedDataInteractionItemProviders:originalItemProviders]; 63 64 return self.convertItemProvidersBlock(originalItemProviders); 46 65 } 47 66 … … 250 269 } 251 270 271 TEST(DataInteractionTests, AttachmentElementItemProviders) 272 { 273 RetainPtr<WKWebViewConfiguration> configuration = [WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:@"BundleEditingDelegatePlugIn"]; 274 [configuration _setAttachmentElementEnabled:YES]; 275 auto webView = adoptNS([[CustomItemProviderWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()]); 276 [webView synchronouslyLoadTestPageNamed:@"attachment-element"]; 277 278 NSString *injectedTypeIdentifier = @"org.webkit.data"; 279 __block RetainPtr<NSString> injectedString; 280 [webView setConvertItemProvidersBlock:^NSArray *(NSArray *originalItemProviders) 281 { 282 for (UIItemProvider *provider in originalItemProviders) { 283 NSData *injectedData = [provider copyDataRepresentationForTypeIdentifier:injectedTypeIdentifier error:nil]; 284 if (!injectedData.length) 285 continue; 286 injectedString = adoptNS([[NSString alloc] initWithData:injectedData encoding:NSUTF8StringEncoding]); 287 break; 288 } 289 return originalItemProviders; 290 }]; 291 292 auto dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]); 293 [dataInteractionSimulator runFrom:CGPointMake(50, 50) to:CGPointMake(50, 400)]; 294 295 EXPECT_WK_STREQ("hello", [injectedString UTF8String]); 296 } 297 252 298 } // namespace TestWebKitAPI 253 299
Note: See TracChangeset
for help on using the changeset viewer.