Consolidate WebContentReaderIOS and WebContentReaderMac into WebContentReaderCocoa
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 May 2018 00:37:55 +0000 (00:37 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 May 2018 00:37:55 +0000 (00:37 +0000)
commit68f3fd377c5eae67867fccbe9b538f0b19243c98
treea02fd2fe3303c00d0d52c0c8240374039bc74da4
parent1010cbf975553aa55ffedcce9b39db6ba21f57f7
Consolidate WebContentReaderIOS and WebContentReaderMac into WebContentReaderCocoa
https://bugs.webkit.org/show_bug.cgi?id=185340

Reviewed by Tim Horton.

Source/WebCore:

WebContentReader::readURL is currently the only method implemented separately in iOS and macOS platform
WebContentReader files. The implementation across macOS and iOS is nearly identical (with some exceptions with
the way iOS handles file URLs and plain text editing), so we can merge these into a single method
WebContentReaderCocoa and delete WebContentReaderIOS and WebContentReaderMac.

This also has the added bonus of fixing a latent bug in WebContentReaderMac, wherein URLs written to the
pasteboard using -[NSPasteboard writeObjects:] are currently pasted as empty anchor elements. In this case, the
link title isn't made explicit, so the `title` passed in to WebContentReader::readURL is empty. On iOS, we have
code to fall back to pasting the absolute string of the URL if the title is empty, but on macOS, we'll just use
this empty string as the title of the anchor.

Test: PasteMixedContent.PasteURLWrittenToPasteboardUsingWriteObjects

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::WebContentReader::readURL):
* editing/ios/WebContentReaderIOS.mm: Removed.
* editing/mac/WebContentReaderMac.mm: Removed.

Tools:

Adds a new API test to verify that URLs written using -[NSPasteboard writeObjects:] are pasted as anchors with
non-empty text in a contenteditable.

* TestWebKitAPI/Tests/WebKitCocoa/PasteMixedContent.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/editing/ios/WebContentReaderIOS.mm [deleted file]
Source/WebCore/editing/mac/WebContentReaderMac.mm [deleted file]
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteMixedContent.mm