Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6c8ce53a001b3a2e951b7d3e0ac891fc4b691c43
https://github.com/WebKit/WebKit/commit/6c8ce53a001b3a2e951b7d3e0ac891fc4b691c43
Author: Richard Robinson <[email protected]>
Date: 2025-05-02 (Fri, 02 May 2025)
Changed paths:
M Source/WebKit/Configurations/WebKitSwift.xcconfig
M Source/WebKit/WebKitSwift/TextExtraction/WKTextExtractionItem.h
M Source/WebKit/WebKitSwift/TextExtraction/WKTextExtractionItem.swift
M Source/WebKit/WebKitSwift/TextExtraction/WKWebView+TextExtraction.swift
Log Message:
-----------
[Swift in WebKit] The Swift implementation of TextExtraction types is
incorrect
https://bugs.webkit.org/show_bug.cgi?id=292422
rdar://150497419
Reviewed by Aditya Keerthi and Wenson Hsieh.
Work towards being able to move Text Extraction code to WebKit proper.
The WKTextExtractionItem and related types were previously incorrectly
implemented in Swift;
they were essentially using a form of forward-declarations, rather than using
the language
support for Swift implementations of Obj-C interfaces (`@objc
@implementation`), which offers
significant benefits such as:
1. Being built-in as a language feature and the intended way to implement this
mechanism
2. Compile-time checking of types, so that the Obj-C interface and the Swift
implementation are never out-of-sync
3. Removes redundant type declarations for enums
4. Removes the need to specify availability versions and make all Swift types
`public`
5. Enforces consistent naming conventions
Fix by making all the relevant types adopt `@objc @implementation`.
* Source/WebKit/WebKitSwift/TextExtraction/WKTextExtractionItem.h:
- Use `NS_ASSUME_NONNULL_BEGIN` so that the null-ness of the types are
consistent between Obj-C and Swift
- Add nullability annotations where needed
- Add a missing initializer declaration to `WKTextExtractionRequest`
- Remove the redundant definition of the `WKTextExtractionContainer` enum
* Source/WebKit/WebKitSwift/TextExtraction/WKTextExtractionItem.swift:
- Use `@objc @implementation` for all types and remove `@objc public` everywhere
- Remove all now-unnecessary availability annotations
(WKTextExtractionLink.url):
- Workaround a limitation of `@objc @implementation` (detailed in an inline
comment)
(WKTextExtractionRequest.fulfill(_:)):
- Use the proper Swift spelling of this function
* Source/WebKit/WebKitSwift/TextExtraction/WKWebView+TextExtraction.swift:
(createEditable(for:)):
- Drive-by improvement: Use the standard `nil` value instead of `Optional.none`
(WKWebView._requestTextExtraction(in:completionHandler:)):
- Use the proper Swift spelling of this function
Canonical link: https://commits.webkit.org/294442@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