Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: aa2ee992eb3e8b7cbfaff4b817375c93b2a0dfa1
      
https://github.com/WebKit/WebKit/commit/aa2ee992eb3e8b7cbfaff4b817375c93b2a0dfa1
  Author: Richard Robinson <[email protected]>
  Date:   2026-03-16 (Mon, 16 Mar 2026)

  Changed paths:
    M Source/WTF/wtf/CheckedRef.h
    M Source/WebCore/platform/SelectionGeometry.h
    M Source/WebCore/platform/graphics/IntRect.h
    M Source/WebKit/Shared/EditorState.h
    M Source/WebKit/UIProcess/WebPageProxy.swift
    M Source/WebKit/UIProcess/mac/WKTextSelectionController.swift
    M Source/WebKit/UIProcess/mac/WebViewImpl.h

  Log Message:
  -----------
  [Swift in WebKit] Add a few more safety annotations across WebKit to be able 
to remove some `unsafe` uses
https://bugs.webkit.org/show_bug.cgi?id=309991
rdar://172619877

Reviewed by Abrar Rahman Protyasha.

Add safety annotations acros various files in WebKit to be able to remove 
`unsafe` from uses of `WebViewImpl`
and `EditorState`.

* Source/WTF/wtf/CheckedRef.h:

Like other smart pointer types, add `SWIFT_RETURNED_AS_UNRETAINED_BY_DEFAULT` 
to `CanMakeCheckedPtrBase` to
indicate that functions which return this type or derived types return them as 
unretained.

* Source/WebCore/platform/SelectionGeometry.h:
* Source/WebCore/platform/graphics/IntRect.h:

Mark these types as `SWIFT_ESCAPABLE`. This type is indeed escapable because it 
is a POD type with
only trivial value types as members, who themselves are all safe.

This is needed because these types are part of `EditorState`. With these 
annotations, `EditorState` is now safe.

* Source/WebKit/Shared/EditorState.h:

Add some missing imports.

* Source/WebKit/UIProcess/WebPageProxy.swift:
(WebKit.editorState):
* Source/WebKit/UIProcess/mac/WKTextSelectionController.swift:
(WKTextSelectionController.selectionDidChange):
(WKTextSelectionController.insertionCursorRect):
(WKTextSelectionController.selectionIsInsertionPoint):
(WKTextSelectionController.isTextSelected(at:)):
(WKTextSelectionController.moveInsertionCursor(to:placeAtWordBoundary:)):
(WKTextSelectionController.showContextMenu(at:)):

Remove `unsafe`.

* Source/WebKit/UIProcess/mac/WebViewImpl.h:

Use `SWIFT_SHARED_REFERENCE` with the CanMakeCheckedPtrBase reference counting 
functions instead of `SWIFT_UNSAFE_REFERENCE`.
This makes `WebViewImpl` considered safe to use from Swift.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to