Changeset 211906 in webkit


Ignore:
Timestamp:
Feb 8, 2017 3:30:52 PM (7 years ago)
Author:
Wenson Hsieh
Message:

Add kUTTypeUTF8PlainText and kUTTypeJPEG to the list of compatible content types in DragData
https://bugs.webkit.org/show_bug.cgi?id=167942
<rdar://problem/30315079>

Reviewed by Tim Horton.

Source/WebCore:

Adds UTI types for dragging UTF8 plain text and JPEG images to the list of supported types in DragDataMac.mm.
Also handles reading these types in PasteboardMac.mm. I verified manually with a test app that if a platform
NSView vends only UTF8 plaintext or JPEG images when dragging, WebKit is able to read the contents of the
pasteboard as text and an image, respectively.

New TestWebKitAPI tests in DragAndDropPasteboardTests.mm.

  • platform/mac/DragDataMac.mm:

(WebCore::DragData::containsCompatibleContent):

  • platform/mac/PasteboardMac.mm:

(WebCore::Pasteboard::read):

Tools:

Adds a new test case that simulates dragging from a source that only vends JPEG images or UTF8 plaintext into a
contenteditable area. An image element and the plain text content, respectively, should be inserted into the
contenteditable in these cases.

The DragSource and DragInfo are used to mock dragging into the WebView. There is no reliance on using mouse
events in this test, since we call the dragging delegate methods (draggingEntered:, draggingUpdated:, and
performDragOperation:) directly.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm: Added.

(+[FrameLoadCompletionListener listenerWithCompletionBlock:]):
(-[FrameLoadCompletionListener initWithCompletionBlock:]):
(-[FrameLoadCompletionListener webView:didFinishLoadForFrame:]):
(-[DragSource draggingSourceOperationMaskForLocal:]):
(-[DragInfo initWithImage:offset:pasteboard:source:destinationWindow:]):
(-[DragInfo lastMousePosition]):
(-[DragInfo setLastMousePosition:]):
(-[DragInfo draggingDestinationWindow]):
(-[DragInfo draggingSourceOperationMask]):
(-[DragInfo draggingLocation]):
(-[DragInfo draggedImageLocation]):
(-[DragInfo draggedImage]):
(-[DragInfo draggingPasteboard]):
(-[DragInfo draggingSource]):
(-[DragInfo draggingSequenceNumber]):
(-[DragInfo slideDraggedImageTo:]):
(-[DragInfo namesOfPromisedFilesDroppedAtDestination:]):
(-[DragInfo draggingFormation]):
(-[DragInfo setDraggingFormation:]):
(-[DragInfo animatesToDestination]):
(-[DragInfo setAnimatesToDestination:]):
(-[DragInfo numberOfValidItemsForDrop]):
(-[DragInfo setNumberOfValidItemsForDrop:]):
(-[DragInfo enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:]):
(-[DragInfo springLoadingHighlight]):
(-[DragInfo resetSpringLoading]):
(TestWebKitAPI::getTestImage):
(TestWebKitAPI::webViewAfterPerformingDragOperation):
(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/mac/full-page-contenteditable.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211905 r211906  
     12017-02-08  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add kUTTypeUTF8PlainText and kUTTypeJPEG to the list of compatible content types in DragData
     4        https://bugs.webkit.org/show_bug.cgi?id=167942
     5        <rdar://problem/30315079>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds UTI types for dragging UTF8 plain text and JPEG images to the list of supported types in DragDataMac.mm.
     10        Also handles reading these types in PasteboardMac.mm. I verified manually with a test app that if a platform
     11        NSView vends only UTF8 plaintext or JPEG images when dragging, WebKit is able to read the contents of the
     12        pasteboard as text and an image, respectively.
     13
     14        New TestWebKitAPI tests in DragAndDropPasteboardTests.mm.
     15
     16        * platform/mac/DragDataMac.mm:
     17        (WebCore::DragData::containsCompatibleContent):
     18        * platform/mac/PasteboardMac.mm:
     19        (WebCore::Pasteboard::read):
     20
    1212017-02-08  Said Abou-Hallawa  <sabouhallawa@apple.com>
    222
  • trunk/Source/WebCore/platform/mac/DragDataMac.mm

    r211342 r211906  
    205205        || types.contains(rtfdPasteboardType())
    206206        || types.contains(rtfPasteboardType())
     207        || types.contains(String(kUTTypeUTF8PlainText))
    207208        || types.contains(stringPasteboardType())
    208209        || types.contains(colorPasteboardType())
     210        || types.contains(String(kUTTypeJPEG))
    209211        || types.contains(String(kUTTypePNG));
    210212}
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r211438 r211906  
    415415    }
    416416
     417    if (types.contains(String(kUTTypeJPEG))) {
     418        if (RefPtr<SharedBuffer> buffer = strategy.bufferForType(kUTTypeJPEG, m_pasteboardName)) {
     419            if (reader.readImage(buffer.releaseNonNull(), ASCIILiteral("image/jpeg")))
     420                return;
     421        }
     422    }
     423
    417424    if (types.contains(String(NSURLPboardType))) {
    418425        URL url = strategy.url(m_pasteboardName);
     
    424431    if (types.contains(String(NSStringPboardType))) {
    425432        String string = strategy.stringForType(NSStringPboardType, m_pasteboardName);
     433        if (!string.isNull() && reader.readPlainText(string))
     434            return;
     435    }
     436
     437    if (types.contains(String(kUTTypeUTF8PlainText))) {
     438        String string = strategy.stringForType(kUTTypeUTF8PlainText, m_pasteboardName);
    426439        if (!string.isNull() && reader.readPlainText(string))
    427440            return;
  • trunk/Tools/ChangeLog

    r211891 r211906  
     12017-02-08  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add kUTTypeUTF8PlainText and kUTTypeJPEG to the list of compatible content types in DragData
     4        https://bugs.webkit.org/show_bug.cgi?id=167942
     5        <rdar://problem/30315079>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds a new test case that simulates dragging from a source that only vends JPEG images or UTF8 plaintext into a
     10        contenteditable area. An image element and the plain text content, respectively, should be inserted into the
     11        contenteditable in these cases.
     12
     13        The DragSource and DragInfo are used to mock dragging into the WebView. There is no reliance on using mouse
     14        events in this test, since we call the dragging delegate methods (draggingEntered:, draggingUpdated:, and
     15        performDragOperation:) directly.
     16
     17        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     18        * TestWebKitAPI/Tests/mac/DragAndDropPasteboardTests.mm: Added.
     19        (+[FrameLoadCompletionListener listenerWithCompletionBlock:]):
     20        (-[FrameLoadCompletionListener initWithCompletionBlock:]):
     21        (-[FrameLoadCompletionListener webView:didFinishLoadForFrame:]):
     22        (-[DragSource draggingSourceOperationMaskForLocal:]):
     23        (-[DragInfo initWithImage:offset:pasteboard:source:destinationWindow:]):
     24        (-[DragInfo lastMousePosition]):
     25        (-[DragInfo setLastMousePosition:]):
     26        (-[DragInfo draggingDestinationWindow]):
     27        (-[DragInfo draggingSourceOperationMask]):
     28        (-[DragInfo draggingLocation]):
     29        (-[DragInfo draggedImageLocation]):
     30        (-[DragInfo draggedImage]):
     31        (-[DragInfo draggingPasteboard]):
     32        (-[DragInfo draggingSource]):
     33        (-[DragInfo draggingSequenceNumber]):
     34        (-[DragInfo slideDraggedImageTo:]):
     35        (-[DragInfo namesOfPromisedFilesDroppedAtDestination:]):
     36        (-[DragInfo draggingFormation]):
     37        (-[DragInfo setDraggingFormation:]):
     38        (-[DragInfo animatesToDestination]):
     39        (-[DragInfo setAnimatesToDestination:]):
     40        (-[DragInfo numberOfValidItemsForDrop]):
     41        (-[DragInfo setNumberOfValidItemsForDrop:]):
     42        (-[DragInfo enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:]):
     43        (-[DragInfo springLoadingHighlight]):
     44        (-[DragInfo resetSpringLoading]):
     45        (TestWebKitAPI::getTestImage):
     46        (TestWebKitAPI::webViewAfterPerformingDragOperation):
     47        (TestWebKitAPI::TEST):
     48        * TestWebKitAPI/Tests/mac/full-page-contenteditable.html: Added.
     49
    1502017-02-08  Jer Noble  <jer.noble@apple.com>
    251
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r211746 r211906  
    550550                F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
    551551                F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
     552                F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */; };
     553                F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
    552554                F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
    553555                F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
     
    623625                        dstSubfolderSpec = 7;
    624626                        files = (
     627                                F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */,
    625628                                C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */,
    626629                                C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */,
     
    13611364                F415086C1DA040C10044BE9B /* play-audio-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "play-audio-on-click.html"; sourceTree = "<group>"; };
    13621365                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; };
     1366                F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-page-contenteditable.html"; sourceTree = "<group>"; };
     1367                F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = "<group>"; };
    13631368                F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
    13641369                F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
     
    21192124                                3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */,
    21202125                                939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */,
     2126                                F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */,
    21212127                                37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */,
    21222128                                2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */,
     
    21812187                                37DC678F140D7D3A00ABCCDB /* DOMRangeOfString.html */,
    21822188                                1A7E8B351812093600AEB74A /* FragmentNavigation.html */,
     2189                                F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */,
    21832190                                CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */,
    21842191                                9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */,
     
    27842791                                52D673EE1AFB127300FA19FE /* WKPageCopySessionStateWithFiltering.cpp in Sources */,
    27852792                                7CCE7F1F1A411AE600447C4C /* WKPageGetScaleFactorNotZero.cpp in Sources */,
     2793                                F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */,
    27862794                                7CCE7F201A411AE600447C4C /* WKPageIsPlayingAudio.cpp in Sources */,
    27872795                                2D00065F1C1F589A0088E6A7 /* WKPDFViewResizeCrash.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.