Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 248632b107f495370f87b9a8f658366f742e4dce
      
https://github.com/WebKit/WebKit/commit/248632b107f495370f87b9a8f658366f742e4dce
  Author: Richard Robinson <[email protected]>
  Date:   2025-07-19 (Sat, 19 Jul 2025)

  Changed paths:
    M Source/WebKit/UIProcess/API/Swift/WebPage+Transferable.swift
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKit Swift/Foundation+Extras.swift
    A Tools/TestWebKitAPI/Tests/WebKit Swift/SwiftUI+Extras.swift
    M Tools/TestWebKitAPI/Tests/WebKit Swift/WebPageNavigationTests.swift
    M Tools/TestWebKitAPI/Tests/WebKit Swift/WebPageTransferableTests.swift

  Log Message:
  -----------
  [SwiftUI] Support more exported content types from WebPage
https://bugs.webkit.org/show_bug.cgi?id=296233
rdar://156225187

Reviewed by Wenson Hsieh.

Add support for exporting the contents of a WebPage as plain text and rich text

* Source/WebKit/UIProcess/API/Swift/WebPage+Transferable.swift:
(transferRepresentation):

- Refine the `.image` export representation to `.png`, which is more specific 
and
usually more useful (for example, it can infer a file extension).

- Expose additional representations for `.flatRTFD`, `.rtf`, and 
`.utf8PlainText`

(WebPage.plainTextRepresentation):

- Use existing WebKit functionality to get the contents of all frames as a 
String, a
nd use its data for the export.

(WebPage.richTextRepresentation(_:)):

- Use existing WebKit functionality to get the contents of the page as an 
NSAttributedString
with a specified document type, and then use its data for the export along with 
the relevant
document attributes.

* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit Swift/Foundation+Extras.swift:
(AsyncSequence.wait(_:)):
(URL.aboutBlank): Deleted.

- Fix some formatting
- Replace the Array extension with the RangeReplaceableCollection extension 
since having both
was redundant
- Add a convenience extension function to AsyncSequence to wait until the 
sequence is finished.
- No need for an `aboutBlank` property anymore now that the API supports 
default values for base URLs.

* Tools/TestWebKitAPI/Tests/WebKit Swift/SwiftUI+Extras.swift: Added.

- Make it easier to convert between an AttributedString's CocoaAttributes' 
fonts values and SwiftUI's
`Font` type.

* Tools/TestWebKitAPI/Tests/WebKit Swift/WebPageNavigationTests.swift:
(WebPageNavigationTests.basicNavigationProducesExpectedNavigationEvents):
(WebPageNavigationTests.failedNavigationProducesExpectedNavigationError):
(WebPageNavigationTests.explicitlyStopLoadingProgrammaticNavigation):
(WebPageNavigationTests.stopLoadingProgrammaticNavigationViaTaskCancellation):
(WebPageNavigationTests.failedNavigationWithWebContentProcessTerminated):
(WebPageNavigationTests.navigationProceedsAfterDiscardingNavigationStream):

- Use the updated convenience APIs to simplify some of the code
- Fix formatting/linting issues

* Tools/TestWebKitAPI/Tests/WebKit Swift/WebPageTransferableTests.swift:
(WebPageTransferableTests.transferableContentTypes):
(WebPageTransferableTests.exportToPDFWithFullContent):
(WebPageTransferableTests.exportToPDFWithSubRegion):
(WebPageTransferableTests.exportToURL):
(WebPageTransferableTests.exportToImage(_:)):
(WebPageTransferableTests.exportToPlainText(_:)):
(WebPageTransferableTests.exportToRichTextWithDocumentAttributes(_:)):
(WebPageTransferableTests.exportToImage): Deleted.

Add tests for all the new exportable content types.

Canonical link: https://commits.webkit.org/297658@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to