[webkit-changes] [WebKit/WebKit] 0b4f1f: Replace `-layoutHasChanged` and `-updateForChanged...

Wenson Hsieh noreply at github.com
Fri Nov 17 16:13:42 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0b4f1f99201e4820a2b8727d68a6ba57b3785457
      https://github.com/WebKit/WebKit/commit/0b4f1f99201e4820a2b8727d68a6ba57b3785457
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-11-17 (Fri, 17 Nov 2023)

  Changed paths:
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

  Log Message:
  -----------
  Replace `-layoutHasChanged` and `-updateForChangedSelection` with `-[UIAsyncTextInputDelegate invalidateTextEntryContext]`
https://bugs.webkit.org/show_bug.cgi?id=265054
rdar://118467892

Reviewed by Megan Gardner.

Adopt `-[UIAsyncTextInputDelegate invalidateTextEntryContext]`, which is a direct replacement for
`-[UIKeyboardImpl updateForChangedSelection]`. Since the latter also updates marked text UI if
needed, we can also replace the `-layoutHasChanged` call with this new method as well.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKRelativeTextRange isEmpty]):

Some drive-by fixes after the introduction of `WKRelativeTextRange` in 270847 at main:

1.  Enforce type safety in `-selectionRectsForRange:` and `-caretRectForPosition:`, in case any
    system client calls these methods using a relative range.

2.  Fix `-[WKRelativeTextRange isEmpty]` so that it returns `YES` only in the case where the offsets
    are equal, *and* the anchors are the same.

3.  Return `nil` in `-positionFromPosition:offset:` and `-textRangeFromPosition:toPosition:` instead
    of `WKRelativeText{Range|Position}`, if the given positions are either not already relative to
    the selection, or the given positions are not identical to the selection start/end. This is
    possible if UIKit asks for `-markedTextRange`, and then asks for positions offset from the start
    or end of the marked text.

(-[WKContentView replaceForWebView:]):

Another drive-by fix: the plan for handling `-replace:` has pivoted slightly, such that we're going
to instead call a new protocol method on the sytem input delegate, instead of calling into the
superclass. Adjust for that here.

(-[WKContentView caretRectForPosition:]):
(-[WKContentView selectionRectsForRange:]):
(-[WKContentView _isAnchoredToCurrentSelection:]):
(-[WKContentView textRangeFromPosition:toPosition:]):
(-[WKContentView positionFromPosition:offset:]):
(-[WKContentView _updateInputContextAfterBlurringAndRefocusingElement]):
(-[WKContentView _selectionChanged]):
(-[WKContentView setAsyncSystemInputDelegate:]):

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




More information about the webkit-changes mailing list