Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fe6d2ca5f95efcc19c4c15f2edfc52d2849921f7
      
https://github.com/WebKit/WebKit/commit/fe6d2ca5f95efcc19c4c15f2edfc52d2849921f7
  Author: Aditya Keerthi <[email protected]>
  Date:   2025-05-07 (Wed, 07 May 2025)

  Changed paths:
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm

  Log Message:
  -----------
  [iOS] Caret may be misplaced when the web view is zoomed
https://bugs.webkit.org/show_bug.cgi?id=292672
rdar://150784478

Reviewed by Wenson Hsieh and Megan Gardner.

Currently, there exists logic to counterscale the caret rect when zoomed, so 
that
the caret remains at a fixed size.

However, this logic appears to be both incorrect and unnecessary.

1. `_scaledCaretRectForSelectionEnd` changes the origin of the rect, in addition
   to changing the size, while `_scaledCaretRectForSelectionStart` does not.
   When zoomed, this results in the "end rect" being moved before the "start 
rect".
   For a caret (non-ranged) selection, the two rects must be equal.

2. UIKit already appears to perform counterscaling. Removing the logic does not
   result in a larger caret when zooming.

Consequently, fix by removing the counterscaling logic in WebKit.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView selectedTextRange]):
(-[WKContentView inverseScale]): Deleted.
(-[WKContentView _scaledCaretRectForSelectionStart:]): Deleted.
(-[WKContentView _scaledCaretRectForSelectionEnd:]): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/EditorStateTests.mm:
(TestWebKitAPI::TEST(EditorStateTests, 
SelectedTextRange_CaretSelectionWithZoom)):

Before this fix, the values of the start and end were the following:

Start: (x = 137, y = 106), size = (width = 0.75, height = 25)
End: (x = 134.75, y = 106), size = (width = 0.75, height = 25)

x=134.75 is a misplaced caret.

Canonical link: https://commits.webkit.org/294649@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